(CMPBconst (ANDLconst [c] x) [0]) -> (TESTBconst [int64(int8(c))] x)
// Convert TESTx to TESTxconst if possible.
-(TESTQ (MOVQconst [c]) x) && c < 1<<31 -> (TESTQconst [c] x)
+(TESTQ (MOVQconst [c]) x) && is32Bit(c) -> (TESTQconst [c] x)
(TESTL (MOVLconst [c]) x) -> (TESTLconst [c] x)
(TESTW (MOVLconst [c]) x) -> (TESTWconst [c] x)
(TESTB (MOVLconst [c]) x) -> (TESTBconst [c] x)
-(TESTQ x (MOVQconst [c])) && c < 1<<31 -> (TESTQconst [c] x)
+(TESTQ x (MOVQconst [c])) && is32Bit(c) -> (TESTQconst [c] x)
(TESTL x (MOVLconst [c])) -> (TESTLconst [c] x)
(TESTW x (MOVLconst [c])) -> (TESTWconst [c] x)
(TESTB x (MOVLconst [c])) -> (TESTBconst [c] x)
return true
}
// match: (TESTQ (MOVQconst [c]) x)
- // cond: c < 1<<31
+ // cond: is32Bit(c)
// result: (TESTQconst [c] x)
for {
v_0 := v.Args[0]
}
c := v_0.AuxInt
x := v.Args[1]
- if !(c < 1<<31) {
+ if !(is32Bit(c)) {
break
}
v.reset(OpAMD64TESTQconst)
return true
}
// match: (TESTQ x (MOVQconst [c]))
- // cond: c < 1<<31
+ // cond: is32Bit(c)
// result: (TESTQconst [c] x)
for {
x := v.Args[0]
break
}
c := v_1.AuxInt
- if !(c < 1<<31) {
+ if !(is32Bit(c)) {
break
}
v.reset(OpAMD64TESTQconst)
--- /dev/null
+// compile
+
+// 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 p
+
+type NodeLink struct{}
+
+// A role our end of NodeLink is intended to play
+type LinkRole int64
+
+const (
+ LinkServer LinkRole = iota // link created as server
+ LinkClient // link created as client
+
+ // for testing:
+ linkNoRecvSend LinkRole = 1 << 16 // do not spawn serveRecv & serveSend
+ linkFlagsMask LinkRole = (1<<32 - 1) << 16
+)
+
+func NewNodeLink(role LinkRole) *NodeLink {
+ var nextConnId uint32
+ switch role &^ linkFlagsMask {
+ case LinkServer:
+ nextConnId = 0 // all initiated by us connId will be even
+ case LinkClient:
+ nextConnId = 1 // ----//---- odd
+ default:
+ panic("invalid conn role")
+ }
+
+ _ = nextConnId
+ return nil
+}