(Div32 x y) ->
(SUB (XOR <config.fe.TypeUInt32()> // negate the result if one operand is negative
- (Select0 <config.fe.TypeUInt32()> (UDIVrtcall
+ (Select0 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)}
(SUB <config.fe.TypeUInt32()> (XOR x <config.fe.TypeUInt32()> (Signmask x)) (Signmask x)) // negate x if negative
(SUB <config.fe.TypeUInt32()> (XOR y <config.fe.TypeUInt32()> (Signmask y)) (Signmask y)))) // negate y if negative
(Signmask (XOR <config.fe.TypeUInt32()> x y))) (Signmask (XOR <config.fe.TypeUInt32()> x y)))
-(Div32u x y) -> (Select0 <config.fe.TypeUInt32()> (UDIVrtcall x y))
+(Div32u x y) -> (Select0 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
(Div16 x y) -> (Div32 (SignExt16to32 x) (SignExt16to32 y))
(Div16u x y) -> (Div32u (ZeroExt16to32 x) (ZeroExt16to32 y))
(Div8 x y) -> (Div32 (SignExt8to32 x) (SignExt8to32 y))
(Mod32 x y) ->
(SUB (XOR <config.fe.TypeUInt32()> // negate the result if x is negative
- (Select1 <config.fe.TypeUInt32()> (UDIVrtcall
+ (Select1 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)}
(SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> x (Signmask x)) (Signmask x)) // negate x if negative
(SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> y (Signmask y)) (Signmask y)))) // negate y if negative
(Signmask x)) (Signmask x))
-(Mod32u x y) -> (Select1 <config.fe.TypeUInt32()> (UDIVrtcall x y))
+(Mod32u x y) -> (Select1 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
(Mod16 x y) -> (Mod32 (SignExt16to32 x) (SignExt16to32 y))
(Mod16u x y) -> (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y))
(Mod8 x y) -> (Mod32 (SignExt8to32 x) (SignExt8to32 y))
(MULA (MOVWconst [c]) x a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a)
// div by constant
-(Select0 (UDIVrtcall x (MOVWconst [1]))) -> x
-(Select1 (UDIVrtcall _ (MOVWconst [1]))) -> (MOVWconst [0])
-(Select0 (UDIVrtcall x (MOVWconst [c]))) && isPowerOfTwo(c) -> (SRLconst [log2(c)] x)
-(Select1 (UDIVrtcall x (MOVWconst [c]))) && isPowerOfTwo(c) -> (ANDconst [c-1] x)
+(Select0 (CALLudiv x (MOVWconst [1]))) -> x
+(Select1 (CALLudiv _ (MOVWconst [1]))) -> (MOVWconst [0])
+(Select0 (CALLudiv x (MOVWconst [c]))) && isPowerOfTwo(c) -> (SRLconst [log2(c)] x)
+(Select1 (CALLudiv x (MOVWconst [c]))) && isPowerOfTwo(c) -> (ANDconst [c-1] x)
// constant comparisons
(CMPconst (MOVWconst [x]) [y]) && int32(x)==int32(y) -> (FlagEQ)
(SRAconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(d)>>uint64(c))])
(MUL (MOVWconst [c]) (MOVWconst [d])) -> (MOVWconst [int64(int32(c*d))])
(MULA (MOVWconst [c]) (MOVWconst [d]) a) -> (ADDconst [int64(int32(c*d))] a)
-(Select0 (UDIVrtcall (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(uint32(c)/uint32(d))])
-(Select1 (UDIVrtcall (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(uint32(c)%uint32(d))])
+(Select0 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(uint32(c)/uint32(d))])
+(Select1 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(uint32(c)%uint32(d))])
(ANDconst [c] (MOVWconst [d])) -> (MOVWconst [c&d])
(ANDconst [c] (ANDconst [d] x)) -> (ANDconst [c&d] x)
(ORconst [c] (MOVWconst [d])) -> (MOVWconst [c|d])
_ = b
// match: (Div32 x y)
// cond:
- // result: (SUB (XOR <config.fe.TypeUInt32()> (Select0 <config.fe.TypeUInt32()> (UDIVrtcall (SUB <config.fe.TypeUInt32()> (XOR x <config.fe.TypeUInt32()> (Signmask x)) (Signmask x)) (SUB <config.fe.TypeUInt32()> (XOR y <config.fe.TypeUInt32()> (Signmask y)) (Signmask y)))) (Signmask (XOR <config.fe.TypeUInt32()> x y))) (Signmask (XOR <config.fe.TypeUInt32()> x y)))
+ // result: (SUB (XOR <config.fe.TypeUInt32()> (Select0 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} (SUB <config.fe.TypeUInt32()> (XOR x <config.fe.TypeUInt32()> (Signmask x)) (Signmask x)) (SUB <config.fe.TypeUInt32()> (XOR y <config.fe.TypeUInt32()> (Signmask y)) (Signmask y)))) (Signmask (XOR <config.fe.TypeUInt32()> x y))) (Signmask (XOR <config.fe.TypeUInt32()> x y)))
for {
x := v.Args[0]
y := v.Args[1]
v.reset(OpARMSUB)
v0 := b.NewValue0(v.Pos, OpARMXOR, config.fe.TypeUInt32())
v1 := b.NewValue0(v.Pos, OpSelect0, config.fe.TypeUInt32())
- v2 := b.NewValue0(v.Pos, OpARMUDIVrtcall, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v2 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v2.Aux = config.ctxt.Lookup("udiv", 0)
v3 := b.NewValue0(v.Pos, OpARMSUB, config.fe.TypeUInt32())
v4 := b.NewValue0(v.Pos, OpARMXOR, config.fe.TypeUInt32())
v4.AddArg(x)
_ = b
// match: (Div32u x y)
// cond:
- // result: (Select0 <config.fe.TypeUInt32()> (UDIVrtcall x y))
+ // result: (Select0 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
for {
x := v.Args[0]
y := v.Args[1]
v.reset(OpSelect0)
v.Type = config.fe.TypeUInt32()
- v0 := b.NewValue0(v.Pos, OpARMUDIVrtcall, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v0 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v0.Aux = config.ctxt.Lookup("udiv", 0)
v0.AddArg(x)
v0.AddArg(y)
v.AddArg(v0)
_ = b
// match: (Mod32 x y)
// cond:
- // result: (SUB (XOR <config.fe.TypeUInt32()> (Select1 <config.fe.TypeUInt32()> (UDIVrtcall (SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> x (Signmask x)) (Signmask x)) (SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> y (Signmask y)) (Signmask y)))) (Signmask x)) (Signmask x))
+ // result: (SUB (XOR <config.fe.TypeUInt32()> (Select1 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} (SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> x (Signmask x)) (Signmask x)) (SUB <config.fe.TypeUInt32()> (XOR <config.fe.TypeUInt32()> y (Signmask y)) (Signmask y)))) (Signmask x)) (Signmask x))
for {
x := v.Args[0]
y := v.Args[1]
v.reset(OpARMSUB)
v0 := b.NewValue0(v.Pos, OpARMXOR, config.fe.TypeUInt32())
v1 := b.NewValue0(v.Pos, OpSelect1, config.fe.TypeUInt32())
- v2 := b.NewValue0(v.Pos, OpARMUDIVrtcall, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v2 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v2.Aux = config.ctxt.Lookup("udiv", 0)
v3 := b.NewValue0(v.Pos, OpARMSUB, config.fe.TypeUInt32())
v4 := b.NewValue0(v.Pos, OpARMXOR, config.fe.TypeUInt32())
v4.AddArg(x)
_ = b
// match: (Mod32u x y)
// cond:
- // result: (Select1 <config.fe.TypeUInt32()> (UDIVrtcall x y))
+ // result: (Select1 <config.fe.TypeUInt32()> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
for {
x := v.Args[0]
y := v.Args[1]
v.reset(OpSelect1)
v.Type = config.fe.TypeUInt32()
- v0 := b.NewValue0(v.Pos, OpARMUDIVrtcall, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v0 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(config.fe.TypeUInt32(), config.fe.TypeUInt32()))
+ v0.Aux = config.ctxt.Lookup("udiv", 0)
v0.AddArg(x)
v0.AddArg(y)
v.AddArg(v0)
func rewriteValueARM_OpSelect0(v *Value, config *Config) bool {
b := v.Block
_ = b
- // match: (Select0 (UDIVrtcall x (MOVWconst [1])))
+ // match: (Select0 (CALLudiv x (MOVWconst [1])))
// cond:
// result: x
for {
v_0 := v.Args[0]
- if v_0.Op != OpARMUDIVrtcall {
+ if v_0.Op != OpARMCALLudiv {
break
}
x := v_0.Args[0]
v.AddArg(x)
return true
}
- // match: (Select0 (UDIVrtcall x (MOVWconst [c])))
+ // match: (Select0 (CALLudiv x (MOVWconst [c])))
// cond: isPowerOfTwo(c)
// result: (SRLconst [log2(c)] x)
for {
v_0 := v.Args[0]
- if v_0.Op != OpARMUDIVrtcall {
+ if v_0.Op != OpARMCALLudiv {
break
}
x := v_0.Args[0]
v.AddArg(x)
return true
}
- // match: (Select0 (UDIVrtcall (MOVWconst [c]) (MOVWconst [d])))
+ // match: (Select0 (CALLudiv (MOVWconst [c]) (MOVWconst [d])))
// cond:
// result: (MOVWconst [int64(uint32(c)/uint32(d))])
for {
v_0 := v.Args[0]
- if v_0.Op != OpARMUDIVrtcall {
+ if v_0.Op != OpARMCALLudiv {
break
}
v_0_0 := v_0.Args[0]
func rewriteValueARM_OpSelect1(v *Value, config *Config) bool {
b := v.Block
_ = b
- // match: (Select1 (UDIVrtcall _ (MOVWconst [1])))
+ // match: (Select1 (CALLudiv _ (MOVWconst [1])))
// cond:
// result: (MOVWconst [0])
for {
v_0 := v.Args[0]
- if v_0.Op != OpARMUDIVrtcall {
+ if v_0.Op != OpARMCALLudiv {
break
}
v_0_1 := v_0.Args[1]
v.AuxInt = 0
return true
}
- // match: (Select1 (UDIVrtcall x (MOVWconst [c])))
+ // match: (Select1 (CALLudiv x (MOVWconst [c])))
// cond: isPowerOfTwo(c)
// result: (ANDconst [c-1] x)
for {
v_0 := v.Args[0]
- if v_0.Op != OpARMUDIVrtcall {
+ if v_0.Op != OpARMCALLudiv {
break
}
x := v_0.Args[0]
v.AddArg(x)
return true
}
- // match: (Select1 (UDIVrtcall (MOVWconst [c]) (MOVWconst [d])))
+ // match: (Select1 (CALLudiv (MOVWconst [c]) (MOVWconst [d])))
// cond:
// result: (MOVWconst [int64(uint32(c)%uint32(d))])
for {
v_0 := v.Args[0]
- if v_0.Op != OpARMUDIVrtcall {
+ if v_0.Op != OpARMCALLudiv {
break
}
v_0_0 := v_0.Args[0]