aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/internal/obj/arm/asm5.go8
-rw-r--r--src/runtime/softfloat_arm.go6
-rw-r--r--src/runtime/vlop_arm.s112
3 files changed, 121 insertions, 5 deletions
diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go
index 04b1cb7442..417da44574 100644
--- a/src/cmd/internal/obj/arm/asm5.go
+++ b/src/cmd/internal/obj/arm/asm5.go
@@ -1480,10 +1480,10 @@ func buildop(ctxt *obj.Link) {
deferreturn = ctxt.Lookup("runtime.deferreturn")
- symdiv = ctxt.Lookup("_div")
- symdivu = ctxt.Lookup("_divu")
- symmod = ctxt.Lookup("_mod")
- symmodu = ctxt.Lookup("_modu")
+ symdiv = ctxt.Lookup("runtime._div")
+ symdivu = ctxt.Lookup("runtime._divu")
+ symmod = ctxt.Lookup("runtime._mod")
+ symmodu = ctxt.Lookup("runtime._modu")
var n int
diff --git a/src/runtime/softfloat_arm.go b/src/runtime/softfloat_arm.go
index 8519f4cbd5..726699d720 100644
--- a/src/runtime/softfloat_arm.go
+++ b/src/runtime/softfloat_arm.go
@@ -655,6 +655,10 @@ func sfloat2(pc uint32, regs *[15]uint32) uint32 {
}
// Stubs to pacify vet. Not safe to call from Go.
-// Calls to these functions are inserted by the compiler.
+// Calls to these functions are inserted by the compiler or assembler.
func _sfloat()
func udiv()
+func _div()
+func _divu()
+func _mod()
+func _modu()
diff --git a/src/runtime/vlop_arm.s b/src/runtime/vlop_arm.s
index 7489a65071..6a602ffbb8 100644
--- a/src/runtime/vlop_arm.s
+++ b/src/runtime/vlop_arm.s
@@ -199,6 +199,118 @@ DATA fast_udiv_tab<>+0x38(SB)/4, $0x85868788
DATA fast_udiv_tab<>+0x3c(SB)/4, $0x81828384
GLOBL fast_udiv_tab<>(SB), RODATA, $64
+// The linker will pass numerator in R8
+#define Rn R8
+// The linker expects the result in RTMP
+#define RTMP R11
+
+TEXT runtime·_divu(SB), NOSPLIT, $16-0
+ // It's not strictly true that there are no local pointers.
+ // It could be that the saved registers Rq, Rr, Rs, and Rm
+ // contain pointers. However, the only way this can matter
+ // is if the stack grows (which it can't, udiv is nosplit)
+ // or if a fault happens and more frames are added to
+ // the stack due to deferred functions.
+ // In the latter case, the stack can grow arbitrarily,
+ // and garbage collection can happen, and those
+ // operations care about pointers, but in that case
+ // the calling frame is dead, and so are the saved
+ // registers. So we can claim there are no pointers here.
+ NO_LOCAL_POINTERS
+ MOVW Rq, 4(R13)
+ MOVW Rr, 8(R13)
+ MOVW Rs, 12(R13)
+ MOVW RM, 16(R13)
+
+ MOVW Rn, Rr /* numerator */
+ MOVW g_m(g), Rq
+ MOVW m_divmod(Rq), Rq /* denominator */
+ BL runtime·udiv(SB)
+ MOVW Rq, RTMP
+ MOVW 4(R13), Rq
+ MOVW 8(R13), Rr
+ MOVW 12(R13), Rs
+ MOVW 16(R13), RM
+ RET
+
+TEXT runtime·_modu(SB), NOSPLIT, $16-0
+ NO_LOCAL_POINTERS
+ MOVW Rq, 4(R13)
+ MOVW Rr, 8(R13)
+ MOVW Rs, 12(R13)
+ MOVW RM, 16(R13)
+
+ MOVW Rn, Rr /* numerator */
+ MOVW g_m(g), Rq
+ MOVW m_divmod(Rq), Rq /* denominator */
+ BL runtime·udiv(SB)
+ MOVW Rr, RTMP
+ MOVW 4(R13), Rq
+ MOVW 8(R13), Rr
+ MOVW 12(R13), Rs
+ MOVW 16(R13), RM
+ RET
+
+TEXT runtime·_div(SB),NOSPLIT,$16-0
+ NO_LOCAL_POINTERS
+ MOVW Rq, 4(R13)
+ MOVW Rr, 8(R13)
+ MOVW Rs, 12(R13)
+ MOVW RM, 16(R13)
+ MOVW Rn, Rr /* numerator */
+ MOVW g_m(g), Rq
+ MOVW m_divmod(Rq), Rq /* denominator */
+ CMP $0, Rr
+ BGE d1
+ RSB $0, Rr, Rr
+ CMP $0, Rq
+ BGE d2
+ RSB $0, Rq, Rq
+d0:
+ BL runtime·udiv(SB) /* none/both neg */
+ MOVW Rq, RTMP
+ B out1
+d1:
+ CMP $0, Rq
+ BGE d0
+ RSB $0, Rq, Rq
+d2:
+ BL runtime·udiv(SB) /* one neg */
+ RSB $0, Rq, RTMP
+out1:
+ MOVW 4(R13), Rq
+ MOVW 8(R13), Rr
+ MOVW 12(R13), Rs
+ MOVW 16(R13), RM
+ RET
+
+TEXT runtime·_mod(SB),NOSPLIT,$16-0
+ NO_LOCAL_POINTERS
+ MOVW Rq, 4(R13)
+ MOVW Rr, 8(R13)
+ MOVW Rs, 12(R13)
+ MOVW RM, 16(R13)
+ MOVW Rn, Rr /* numerator */
+ MOVW g_m(g), Rq
+ MOVW m_divmod(Rq), Rq /* denominator */
+ CMP $0, Rq
+ RSB.LT $0, Rq, Rq
+ CMP $0, Rr
+ BGE m1
+ RSB $0, Rr, Rr
+ BL runtime·udiv(SB) /* neg numerator */
+ RSB $0, Rr, RTMP
+ B out
+m1:
+ BL runtime·udiv(SB) /* pos numerator */
+ MOVW Rr, RTMP
+out:
+ MOVW 4(R13), Rq
+ MOVW 8(R13), Rr
+ MOVW 12(R13), Rs
+ MOVW 16(R13), RM
+ RET
+
// _mul64by32 and _div64by32 not implemented on arm
TEXT runtime·_mul64by32(SB), NOSPLIT, $0
MOVW $0, R0