fallthrough
case ssa.OpARMMVN,
ssa.OpARMCLZ,
+ ssa.OpARMREV,
+ ssa.OpARMRBIT,
ssa.OpARMSQRTD,
ssa.OpARMNEGF,
ssa.OpARMNEGD,
(Sqrt x) -> (SQRTD x)
-// count trailing zero
+// count trailing zero for ARMv5 and ARMv6
// 32 - CLZ(x&-x - 1)
-(Ctz32 <t> x) -> (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1])))
+(Ctz32 <t> x) && obj.GOARM<=6 -> (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1])))
+
+// count trailing zero for ARMv7
+(Ctz32 <t> x) && obj.GOARM==7 -> (CLZ <t> (RBIT <t> x))
// bit length
(BitLen32 <t> x) -> (RSBconst [32] (CLZ <t> x))
-// byte swap
+// byte swap for ARMv5
// let (a, b, c, d) be the bytes of x from high to low
// t1 = x right rotate 16 bits -- (c, d, a, b )
// t2 = x ^ t1 -- (a^c, b^d, a^c, b^d)
// t5 = x right rotate 8 bits -- (d, a, b, c )
// result = t4 ^ t5 -- (d, c, b, a )
// using shifted ops this can be done in 4 instructions.
-(Bswap32 <t> x) ->
+(Bswap32 <t> x) && obj.GOARM==5 ->
(XOR <t>
(SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8])
(SRRconst <t> x [8]))
+// byte swap for ARMv6 and above
+(Bswap32 x) && obj.GOARM>=6 -> (REV x)
+
// boolean ops -- booleans are represented with 0=false, 1=true
(AndB x y) -> (AND x y)
(OrB x y) -> (OR x y)
{name: "NEGD", argLength: 1, reg: fp11, asm: "NEGD"}, // -arg0, float64
{name: "SQRTD", argLength: 1, reg: fp11, asm: "SQRTD"}, // sqrt(arg0), float64
- {name: "CLZ", argLength: 1, reg: gp11, asm: "CLZ"}, // count leading zero
+ {name: "CLZ", argLength: 1, reg: gp11, asm: "CLZ"}, // count leading zero
+ {name: "REV", argLength: 1, reg: gp11, asm: "REV"}, // reverse byte order
+ {name: "RBIT", argLength: 1, reg: gp11, asm: "RBIT"}, // reverse bit order
// shifts
{name: "SLL", argLength: 2, reg: gp21, asm: "SLL"}, // arg0 << arg1, shift amount is mod 256
fmt.Fprintln(w)
fmt.Fprintln(w, "package ssa")
fmt.Fprintln(w, "import \"math\"")
+ fmt.Fprintln(w, "import \"cmd/internal/obj\"")
fmt.Fprintln(w, "var _ = math.MinInt8 // in case not otherwise used")
+ fmt.Fprintln(w, "var _ = obj.ANOP // in case not otherwise used")
// Main rewrite routine is a switch on v.Op.
fmt.Fprintf(w, "func rewriteValue%s(v *Value) bool {\n", arch.name)
OpARMNEGD
OpARMSQRTD
OpARMCLZ
+ OpARMREV
+ OpARMRBIT
OpARMSLL
OpARMSLLconst
OpARMSRL
},
},
},
+ {
+ 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: "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,
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValue386(v *Value) bool {
switch v.Op {
case Op386ADCL:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValueAMD64(v *Value) bool {
switch v.Op {
case OpAMD64ADDL:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValueARM(v *Value) bool {
switch v.Op {
case OpARMADC:
b := v.Block
_ = b
// match: (Bswap32 <t> x)
- // cond:
+ // cond: obj.GOARM==5
// result: (XOR <t> (SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8]) (SRRconst <t> x [8]))
for {
t := v.Type
x := v.Args[0]
+ if !(obj.GOARM == 5) {
+ break
+ }
v.reset(OpARMXOR)
v.Type = t
v0 := b.NewValue0(v.Pos, OpARMSRLconst, t)
v.AddArg(v4)
return true
}
+ // match: (Bswap32 x)
+ // cond: obj.GOARM>=6
+ // result: (REV x)
+ for {
+ x := v.Args[0]
+ if !(obj.GOARM >= 6) {
+ break
+ }
+ v.reset(OpARMREV)
+ v.AddArg(x)
+ return true
+ }
+ return false
}
func rewriteValueARM_OpClosureCall(v *Value) bool {
// match: (ClosureCall [argwid] entry closure mem)
b := v.Block
_ = b
// match: (Ctz32 <t> x)
- // cond:
+ // cond: obj.GOARM<=6
// result: (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1])))
for {
t := v.Type
x := v.Args[0]
+ if !(obj.GOARM <= 6) {
+ break
+ }
v.reset(OpARMRSBconst)
v.AuxInt = 32
v0 := b.NewValue0(v.Pos, OpARMCLZ, t)
v.AddArg(v0)
return true
}
+ // match: (Ctz32 <t> x)
+ // cond: obj.GOARM==7
+ // result: (CLZ <t> (RBIT <t> x))
+ for {
+ t := v.Type
+ x := v.Args[0]
+ if !(obj.GOARM == 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_OpCvt32Fto32(v *Value) bool {
// match: (Cvt32Fto32 x)
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValueARM64(v *Value) bool {
switch v.Op {
case OpARM64ADD:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValueMIPS(v *Value) bool {
switch v.Op {
case OpAdd16:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValueMIPS64(v *Value) bool {
switch v.Op {
case OpAdd16:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValuePPC64(v *Value) bool {
switch v.Op {
case OpAdd16:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValueS390X(v *Value) bool {
switch v.Op {
case OpAdd16:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValuedec(v *Value) bool {
switch v.Op {
case OpComplexImag:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValuedec64(v *Value) bool {
switch v.Op {
case OpAdd64:
package ssa
import "math"
+import "cmd/internal/obj"
var _ = math.MinInt8 // in case not otherwise used
+var _ = obj.ANOP // in case not otherwise used
func rewriteValuegeneric(v *Value) bool {
switch v.Op {
case OpAdd16: