p.From.Offset = v.AuxInt
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
- case ssa.OpARMCALLstatic, ssa.OpARMCALLclosure, ssa.OpARMCALLinter, ssa.OpARMCALLudiv:
+ case ssa.OpARMCALLstatic, ssa.OpARMCALLclosure, ssa.OpARMCALLinter:
+ s.Call(v)
+ case ssa.OpARMCALLudiv:
+ v.Aux = gc.Udiv
s.Call(v)
case ssa.OpARMDUFFZERO:
p := s.Prog(obj.ADUFFZERO)
writeBarrier,
writebarrierptr,
typedmemmove,
- typedmemclr *obj.LSym
+ typedmemclr,
+ Udiv *obj.LSym
)
writebarrierptr = Sysfunc("writebarrierptr")
typedmemmove = Sysfunc("typedmemmove")
typedmemclr = Sysfunc("typedmemclr")
+ Udiv = Sysfunc("udiv")
}
// buildssa builds an SSA function.
(Mul32uhilo x y) -> (MULLU x y)
(Div32 x y) ->
- (SUB (XOR <types.UInt32> // negate the result if one operand is negative
- (Select0 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)}
+ (SUB (XOR <types.UInt32> // negate the result if one operand is negative
+ (Select0 <types.UInt32> (CALLudiv
(SUB <types.UInt32> (XOR x <types.UInt32> (Signmask x)) (Signmask x)) // negate x if negative
(SUB <types.UInt32> (XOR y <types.UInt32> (Signmask y)) (Signmask y)))) // negate y if negative
(Signmask (XOR <types.UInt32> x y))) (Signmask (XOR <types.UInt32> x y)))
-(Div32u x y) -> (Select0 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
+(Div32u x y) -> (Select0 <types.UInt32> (CALLudiv 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))
(Div64F x y) -> (DIVD x y)
(Mod32 x y) ->
- (SUB (XOR <types.UInt32> // negate the result if x is negative
- (Select1 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)}
+ (SUB (XOR <types.UInt32> // negate the result if x is negative
+ (Select1 <types.UInt32> (CALLudiv
(SUB <types.UInt32> (XOR <types.UInt32> x (Signmask x)) (Signmask x)) // negate x if negative
(SUB <types.UInt32> (XOR <types.UInt32> y (Signmask y)) (Signmask y)))) // negate y if negative
(Signmask x)) (Signmask x))
-(Mod32u x y) -> (Select1 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
+(Mod32u x y) -> (Select1 <types.UInt32> (CALLudiv 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))
},
clobberFlags: true,
typ: "(UInt32,UInt32)",
- aux: "SymOff",
- // TODO(mdempsky): Should this be true?
- call: false,
- symEffect: "None",
+ call: false, // TODO(mdempsky): Should this be true?
},
{name: "ADDS", argLength: 2, reg: gp21carry, asm: "ADD", commutative: true}, // arg0 + arg1, set carry flag
},
{
name: "CALLudiv",
- auxType: auxSymOff,
argLen: 2,
clobberFlags: true,
- symEffect: SymNone,
reg: regInfo{
inputs: []inputInfo{
{0, 2}, // R1
func rewriteValueARM_OpDiv32(v *Value) bool {
b := v.Block
_ = b
- config := b.Func.Config
- _ = config
types := &b.Func.Config.Types
_ = types
// match: (Div32 x y)
// cond:
- // result: (SUB (XOR <types.UInt32> (Select0 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)} (SUB <types.UInt32> (XOR x <types.UInt32> (Signmask x)) (Signmask x)) (SUB <types.UInt32> (XOR y <types.UInt32> (Signmask y)) (Signmask y)))) (Signmask (XOR <types.UInt32> x y))) (Signmask (XOR <types.UInt32> x y)))
+ // result: (SUB (XOR <types.UInt32> (Select0 <types.UInt32> (CALLudiv (SUB <types.UInt32> (XOR x <types.UInt32> (Signmask x)) (Signmask x)) (SUB <types.UInt32> (XOR y <types.UInt32> (Signmask y)) (Signmask y)))) (Signmask (XOR <types.UInt32> x y))) (Signmask (XOR <types.UInt32> x y)))
for {
x := v.Args[0]
y := v.Args[1]
v0 := b.NewValue0(v.Pos, OpARMXOR, types.UInt32)
v1 := b.NewValue0(v.Pos, OpSelect0, types.UInt32)
v2 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(types.UInt32, types.UInt32))
- v2.Aux = config.ctxt.Lookup("udiv", 0)
v3 := b.NewValue0(v.Pos, OpARMSUB, types.UInt32)
v4 := b.NewValue0(v.Pos, OpARMXOR, types.UInt32)
v4.AddArg(x)
func rewriteValueARM_OpDiv32u(v *Value) bool {
b := v.Block
_ = b
- config := b.Func.Config
- _ = config
types := &b.Func.Config.Types
_ = types
// match: (Div32u x y)
// cond:
- // result: (Select0 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
+ // result: (Select0 <types.UInt32> (CALLudiv x y))
for {
x := v.Args[0]
y := v.Args[1]
v.reset(OpSelect0)
v.Type = types.UInt32
v0 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(types.UInt32, types.UInt32))
- v0.Aux = config.ctxt.Lookup("udiv", 0)
v0.AddArg(x)
v0.AddArg(y)
v.AddArg(v0)
func rewriteValueARM_OpMod32(v *Value) bool {
b := v.Block
_ = b
- config := b.Func.Config
- _ = config
types := &b.Func.Config.Types
_ = types
// match: (Mod32 x y)
// cond:
- // result: (SUB (XOR <types.UInt32> (Select1 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)} (SUB <types.UInt32> (XOR <types.UInt32> x (Signmask x)) (Signmask x)) (SUB <types.UInt32> (XOR <types.UInt32> y (Signmask y)) (Signmask y)))) (Signmask x)) (Signmask x))
+ // result: (SUB (XOR <types.UInt32> (Select1 <types.UInt32> (CALLudiv (SUB <types.UInt32> (XOR <types.UInt32> x (Signmask x)) (Signmask x)) (SUB <types.UInt32> (XOR <types.UInt32> y (Signmask y)) (Signmask y)))) (Signmask x)) (Signmask x))
for {
x := v.Args[0]
y := v.Args[1]
v0 := b.NewValue0(v.Pos, OpARMXOR, types.UInt32)
v1 := b.NewValue0(v.Pos, OpSelect1, types.UInt32)
v2 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(types.UInt32, types.UInt32))
- v2.Aux = config.ctxt.Lookup("udiv", 0)
v3 := b.NewValue0(v.Pos, OpARMSUB, types.UInt32)
v4 := b.NewValue0(v.Pos, OpARMXOR, types.UInt32)
v4.AddArg(x)
func rewriteValueARM_OpMod32u(v *Value) bool {
b := v.Block
_ = b
- config := b.Func.Config
- _ = config
types := &b.Func.Config.Types
_ = types
// match: (Mod32u x y)
// cond:
- // result: (Select1 <types.UInt32> (CALLudiv {config.ctxt.Lookup("udiv", 0)} x y))
+ // result: (Select1 <types.UInt32> (CALLudiv x y))
for {
x := v.Args[0]
y := v.Args[1]
v.reset(OpSelect1)
v.Type = types.UInt32
v0 := b.NewValue0(v.Pos, OpARMCALLudiv, MakeTuple(types.UInt32, types.UInt32))
- v0.Aux = config.ctxt.Lookup("udiv", 0)
v0.AddArg(x)
v0.AddArg(y)
v.AddArg(v0)
runtime/tls_arm.s: [arm] save_g: function save_g missing Go declaration
runtime/tls_arm.s: [arm] load_g: function load_g missing Go declaration
runtime/tls_arm.s: [arm] _initcgo: function _initcgo missing Go declaration
+runtime/vlop_arm.s: [arm] udiv: function udiv missing Go declaration
// Clearer using FP than SP, but that requires named offsets.
runtime/asm_arm.s: [arm] rt0_go: use of 4(R13) points beyond argument frame
MOVW g_sigpc(g), LR
B runtime·sigpanic(SB)
-// func udiv(n, d uint32) (q, r uint32)
+// func runtime·udiv(n, d uint32) (q, r uint32)
// compiler knowns the register usage of this function
// Reference:
// Sloss, Andrew et. al; ARM System Developer's Guide: Designing and Optimizing System Software
#define Ra R11
// Be careful: Ra == R11 will be used by the linker for synthesized instructions.
-TEXT udiv(SB),NOSPLIT,$-4
+TEXT runtime·udiv(SB),NOSPLIT,$-4
MOVBU runtime·hardDiv(SB), Ra
CMP $0, Ra
BNE udiv_hardware
MOVW Rn, Rr /* numerator */
MOVW g_m(g), Rq
MOVW m_divmod(Rq), Rq /* denominator */
- BL udiv(SB)
+ BL runtime·udiv(SB)
MOVW Rq, RTMP
MOVW 4(R13), Rq
MOVW 8(R13), Rr
MOVW Rn, Rr /* numerator */
MOVW g_m(g), Rq
MOVW m_divmod(Rq), Rq /* denominator */
- BL udiv(SB)
+ BL runtime·udiv(SB)
MOVW Rr, RTMP
MOVW 4(R13), Rq
MOVW 8(R13), Rr
BGE d2
RSB $0, Rq, Rq
d0:
- BL udiv(SB) /* none/both neg */
+ BL runtime·udiv(SB) /* none/both neg */
MOVW Rq, RTMP
B out1
d1:
BGE d0
RSB $0, Rq, Rq
d2:
- BL udiv(SB) /* one neg */
+ BL runtime·udiv(SB) /* one neg */
RSB $0, Rq, RTMP
out1:
MOVW 4(R13), Rq
CMP $0, Rr
BGE m1
RSB $0, Rr, Rr
- BL udiv(SB) /* neg numerator */
+ BL runtime·udiv(SB) /* neg numerator */
RSB $0, Rr, RTMP
B out
m1:
- BL udiv(SB) /* pos numerator */
+ BL runtime·udiv(SB) /* pos numerator */
MOVW Rr, RTMP
out:
MOVW 4(R13), Rq