diff options
| author | Cherry Zhang <cherryyz@google.com> | 2016-09-19 07:45:08 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2016-09-20 13:40:48 +0000 |
| commit | 38cd79889ece342643b56ad6d496ef8931ca9272 (patch) | |
| tree | 798540d48b188adac947c3709d6a2a6f8b4d80c6 /src/runtime | |
| parent | f964810025ae58b623798a1944c39c06266fb45d (diff) | |
| download | go-38cd79889ece342643b56ad6d496ef8931ca9272.tar.xz | |
cmd/compile: simplify div/mod on ARM
On ARM, DIV, DIVU, MOD, MODU are pseudo instructions that makes
runtime calls _div/_udiv/_mod/_umod, which themselves are wrappers
of udiv. The udiv function does the real thing.
Instead of generating these pseudo instructions, call to udiv
directly. This removes one layer of wrappers (which has an awkward
way of passing argument), and also allows combining DIV and MOD
if both results are needed.
Change-Id: I118afc3986db3a1daabb5c1e6e57430888c91817
Reviewed-on: https://go-review.googlesource.com/29390
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/vlop_arm.s | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/runtime/vlop_arm.s b/src/runtime/vlop_arm.s index 1eb23f005c..f371601e29 100644 --- a/src/runtime/vlop_arm.s +++ b/src/runtime/vlop_arm.s @@ -107,6 +107,7 @@ TEXT runtime·_sfloatpanic(SB),NOSPLIT,$-4 B runtime·sigpanic(SB) // func 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 // Morgan Kaufmann; 1 edition (April 8, 2004), ISBN 978-1558608740 @@ -117,7 +118,7 @@ TEXT runtime·_sfloatpanic(SB),NOSPLIT,$-4 #define Ra R11 // Be careful: Ra == R11 will be used by the linker for synthesized instructions. -TEXT udiv<>(SB),NOSPLIT,$-4 +TEXT udiv(SB),NOSPLIT,$-4 CLZ Rq, Rs // find normalizing shift MOVW.S Rq<<Rs, Ra MOVW $fast_udiv_tab<>-64(SB), RM @@ -227,7 +228,7 @@ TEXT _divu(SB), NOSPLIT, $16-0 MOVW RTMP, Rr /* numerator */ MOVW g_m(g), Rq MOVW m_divmod(Rq), Rq /* denominator */ - BL udiv<>(SB) + BL udiv(SB) MOVW Rq, RTMP MOVW 4(R13), Rq MOVW 8(R13), Rr @@ -245,7 +246,7 @@ TEXT _modu(SB), NOSPLIT, $16-0 MOVW RTMP, Rr /* numerator */ MOVW g_m(g), Rq MOVW m_divmod(Rq), Rq /* denominator */ - BL udiv<>(SB) + BL udiv(SB) MOVW Rr, RTMP MOVW 4(R13), Rq MOVW 8(R13), Rr @@ -269,7 +270,7 @@ TEXT _div(SB),NOSPLIT,$16-0 BGE d2 RSB $0, Rq, Rq d0: - BL udiv<>(SB) /* none/both neg */ + BL udiv(SB) /* none/both neg */ MOVW Rq, RTMP B out1 d1: @@ -277,8 +278,8 @@ d1: BGE d0 RSB $0, Rq, Rq d2: - BL udiv<>(SB) /* one neg */ - RSB $0, Rq, RTMP + BL udiv(SB) /* one neg */ + RSB $0, Rq, RTMP out1: MOVW 4(R13), Rq MOVW 8(R13), Rr @@ -300,11 +301,11 @@ TEXT _mod(SB),NOSPLIT,$16-0 CMP $0, Rr BGE m1 RSB $0, Rr, Rr - BL udiv<>(SB) /* neg numerator */ + BL udiv(SB) /* neg numerator */ RSB $0, Rr, RTMP B out m1: - BL udiv<>(SB) /* pos numerator */ + BL udiv(SB) /* pos numerator */ MOVW Rr, RTMP out: MOVW 4(R13), Rq |
