v.Op, v.Args[1].Type.String())
}
}
+ // Check size of args.
+ // This list isn't exhaustive, just the common ops.
+ // It also can't handle ops with args of different types, like shifts.
+ var argSize int64
+ switch v.Op {
+ case OpAdd8, OpSub8, OpMul8, OpDiv8, OpDiv8u, OpMod8, OpMod8u,
+ OpAnd8, OpOr8, OpXor8,
+ OpEq8, OpNeq8, OpLess8, OpLeq8,
+ OpNeg8, OpCom8,
+ OpSignExt8to16, OpSignExt8to32, OpSignExt8to64,
+ OpZeroExt8to16, OpZeroExt8to32, OpZeroExt8to64:
+ argSize = 1
+ case OpAdd16, OpSub16, OpMul16, OpDiv16, OpDiv16u, OpMod16, OpMod16u,
+ OpAnd16, OpOr16, OpXor16,
+ OpEq16, OpNeq16, OpLess16, OpLeq16,
+ OpNeg16, OpCom16,
+ OpSignExt16to32, OpSignExt16to64,
+ OpZeroExt16to32, OpZeroExt16to64,
+ OpTrunc16to8:
+ argSize = 2
+ case OpAdd32, OpSub32, OpMul32, OpDiv32, OpDiv32u, OpMod32, OpMod32u,
+ OpAnd32, OpOr32, OpXor32,
+ OpEq32, OpNeq32, OpLess32, OpLeq32,
+ OpNeg32, OpCom32,
+ OpSignExt32to64, OpZeroExt32to64,
+ OpTrunc32to8, OpTrunc32to16:
+ argSize = 4
+ case OpAdd64, OpSub64, OpMul64, OpDiv64, OpDiv64u, OpMod64, OpMod64u,
+ OpAnd64, OpOr64, OpXor64,
+ OpEq64, OpNeq64, OpLess64, OpLeq64,
+ OpNeg64, OpCom64,
+ OpTrunc64to8, OpTrunc64to16, OpTrunc64to32:
+ argSize = 8
+ }
+ if argSize != 0 {
+ for i, arg := range v.Args {
+ if arg.Type.Size() != argSize {
+ f.Fatalf("arg %d to %s (%v) should be %d bytes in size, it is %s", i, v.Op, v, argSize, arg.Type.String())
+ }
+ }
+ }
// TODO: check for cycles in values
}
// 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])
+ return s.newValue1(ssa.OpBitRev64, types.Types[types.TUINT64], 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])
+ return s.newValue1(ssa.OpBitRev32, types.Types[types.TUINT32], 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])
+ return s.newValue1(ssa.OpBitRev16, types.Types[types.TUINT16], 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])
+ return s.newValue1(ssa.OpBitRev8, types.Types[types.TUINT8], 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])
+ return s.newValue1(ssa.OpBitRev64, types.Types[types.TUINT], args[0])
},
sys.ARM64, sys.Loong64)
addF("math/bits", "RotateLeft8",
// byte N matched).
//
// NOTE: See comment above on bitsetFirst.
- out := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], eq)
+ out := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT8], eq)
// g is only 64-bits so the upper 64-bits of the
// 128-bit register will be zero. If h2 is also zero,
// means byte N matched).
//
// NOTE: See comment above on bitsetFirst.
- ret := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], sign)
+ ret := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT64], sign)
// g is only 64-bits so the upper 64-bits of
// the 128-bit register will be zero. PSIGNB
// byte N matched).
//
// NOTE: See comment above on bitsetFirst.
- out := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], eq)
+ out := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT8], eq)
// g is only 64-bits so the upper 64-bits of the
// 128-bit register will be zero. The upper 64-bits of
// byte N matched).
//
// NOTE: See comment above on bitsetFirst.
- ret := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], gfp)
+ ret := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT64], gfp)
// g is only 64-bits so the upper 64-bits of the
// 128-bit register will be zero. Zero will never match
// byte N matched).
//
// NOTE: See comment above on bitsetFirst.
- mask := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT16], gfp)
+ mask := s.newValue1(ssa.OpAMD64PMOVMSKB, types.Types[types.TUINT8], gfp)
// Invert the mask to set the bits for the full slots.
- out := s.newValue1(ssa.OpCom16, types.Types[types.TUINT16], mask)
+ out := s.newValue1(ssa.OpCom8, types.Types[types.TUINT8], mask)
// g is only 64-bits so the upper 64-bits of the
// 128-bit register will be zero, with bit 7 unset.