Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
73374c93
Commit
73374c93
authored
Apr 20, 2010
by
Evan Shaw
Committed by
Robert Griesemer
Apr 20, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
big: Get rid of function pointers and init function
R=rsc, gri CC=golang-dev
https://golang.org/cl/929041
parent
8df31213
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
89 deletions
+43
-89
arith.go
src/pkg/big/arith.go
+7
-53
arith_386.s
src/pkg/big/arith_386.s
+15
-15
arith_amd64.s
src/pkg/big/arith_amd64.s
+14
-14
arith_arm.s
src/pkg/big/arith_arm.s
+7
-7
No files found.
src/pkg/big/arith.go
View file @
73374c93
...
...
@@ -267,58 +267,12 @@ func divWW_g(x1, x0, y Word) (q, r Word) {
}
// ----------------------------------------------------------------------------
// Elementary operations on vectors
// All higher-level functions use these elementary vector operations.
// The function pointers f are initialized with default implementations
// f_g, written in Go for portability. The corresponding assembly routines
// f_s should be installed if they exist.
var
(
// addVV sets z and returns c such that z+c = x+y.
addVV
func
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
=
addVV_g
// subVV sets z and returns c such that z-c = x-y.
subVV
func
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
=
subVV_g
// addVW sets z and returns c such that z+c = x-y.
addVW
func
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
=
addVW_g
// subVW sets z and returns c such that z-c = x-y.
subVW
func
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
=
subVW_g
// mulAddVWW sets z and returns c such that z+c = x*y + r.
mulAddVWW
func
(
z
,
x
*
Word
,
y
,
r
Word
,
n
int
)
(
c
Word
)
=
mulAddVWW_g
// addMulVVW sets z and returns c such that z+c = z + x*y.
addMulVVW
func
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
=
addMulVVW_g
// divWVW sets z and returns r such that z-r = (xn<<(n*_W) + x) / y.
divWVW
func
(
z
*
Word
,
xn
Word
,
x
*
Word
,
y
Word
,
n
int
)
(
r
Word
)
=
divWVW_g
)
func
init
()
{
// Uncomment to use generic routines.
//return;
// Install assembly routines.
addVV
=
addVV_s
subVV
=
subVV_s
addVW
=
addVW_s
subVW
=
subVW_s
mulAddVWW
=
mulAddVWW_s
addMulVVW
=
addMulVVW_s
divWVW
=
divWVW_s
}
func
(
p
*
Word
)
at
(
i
int
)
*
Word
{
return
(
*
Word
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
p
))
+
uintptr
(
i
)
*
_S
))
}
func
addVV
_s
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
func
addVV
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
func
addVV_g
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
{
for
i
:=
0
;
i
<
n
;
i
++
{
c
,
*
z
.
at
(
i
)
=
addWW_g
(
*
x
.
at
(
i
),
*
y
.
at
(
i
),
c
)
...
...
@@ -327,7 +281,7 @@ func addVV_g(z, x, y *Word, n int) (c Word) {
}
func
subVV
_s
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
func
subVV
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
func
subVV_g
(
z
,
x
,
y
*
Word
,
n
int
)
(
c
Word
)
{
for
i
:=
0
;
i
<
n
;
i
++
{
c
,
*
z
.
at
(
i
)
=
subWW_g
(
*
x
.
at
(
i
),
*
y
.
at
(
i
),
c
)
...
...
@@ -336,7 +290,7 @@ func subVV_g(z, x, y *Word, n int) (c Word) {
}
func
addVW
_s
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
func
addVW
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
func
addVW_g
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
{
c
=
y
for
i
:=
0
;
i
<
n
;
i
++
{
...
...
@@ -346,7 +300,7 @@ func addVW_g(z, x *Word, y Word, n int) (c Word) {
}
func
subVW
_s
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
func
subVW
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
func
subVW_g
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
{
c
=
y
for
i
:=
0
;
i
<
n
;
i
++
{
...
...
@@ -356,7 +310,7 @@ func subVW_g(z, x *Word, y Word, n int) (c Word) {
}
func
mulAddVWW
_s
(
z
,
x
*
Word
,
y
,
r
Word
,
n
int
)
(
c
Word
)
func
mulAddVWW
(
z
,
x
*
Word
,
y
,
r
Word
,
n
int
)
(
c
Word
)
func
mulAddVWW_g
(
z
,
x
*
Word
,
y
,
r
Word
,
n
int
)
(
c
Word
)
{
c
=
r
for
i
:=
0
;
i
<
n
;
i
++
{
...
...
@@ -366,7 +320,7 @@ func mulAddVWW_g(z, x *Word, y, r Word, n int) (c Word) {
}
func
addMulVVW
_s
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
func
addMulVVW
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
func
addMulVVW_g
(
z
,
x
*
Word
,
y
Word
,
n
int
)
(
c
Word
)
{
for
i
:=
0
;
i
<
n
;
i
++
{
z1
,
z0
:=
mulAddWWW_g
(
*
x
.
at
(
i
),
y
,
*
z
.
at
(
i
))
...
...
@@ -377,7 +331,7 @@ func addMulVVW_g(z, x *Word, y Word, n int) (c Word) {
}
func
divWVW
_s
(
z
*
Word
,
xn
Word
,
x
*
Word
,
y
Word
,
n
int
)
(
r
Word
)
func
divWVW
(
z
*
Word
,
xn
Word
,
x
*
Word
,
y
Word
,
n
int
)
(
r
Word
)
func
divWVW_g
(
z
*
Word
,
xn
Word
,
x
*
Word
,
y
Word
,
n
int
)
(
r
Word
)
{
r
=
xn
for
i
:=
n
-
1
;
i
>=
0
;
i
--
{
...
...
src/pkg/big/arith_386.s
View file @
73374c93
...
...
@@ -5,8 +5,8 @@
// This file provides fast assembly versions for the elementary
// arithmetic operations on vectors implemented in arith.go.
// func addVV
_s
(z, x, y *Word, n int) (c Word)
TEXT ·addVV
_s
(SB),7,$0
// func addVV(z, x, y *Word, n int) (c Word)
TEXT ·addVV(SB),7,$0
MOVL z+0(FP), DI
MOVL x+4(FP), SI
MOVL y+8(FP), CX
...
...
@@ -29,9 +29,9 @@ E1: CMPL BX, BP // i < n
RET
// func subVV
_s
(z, x, y *Word, n int) (c Word)
// (same as addVV
_s
except for SBBL instead of ADCL and label names)
TEXT ·subVV
_s
(SB),7,$0
// func subVV(z, x, y *Word, n int) (c Word)
// (same as addVV except for SBBL instead of ADCL and label names)
TEXT ·subVV(SB),7,$0
MOVL z+0(FP), DI
MOVL x+4(FP), SI
MOVL y+8(FP), CX
...
...
@@ -54,8 +54,8 @@ E2: CMPL BX, BP // i < n
RET
// func addVW
_s
(z, x *Word, y Word, n int) (c Word)
TEXT ·addVW
_s
(SB),7,$0
// func addVW(z, x *Word, y Word, n int) (c Word)
TEXT ·addVW(SB),7,$0
MOVL z+0(FP), DI
MOVL x+4(FP), SI
MOVL y+8(FP), AX // c = y
...
...
@@ -76,8 +76,8 @@ E3: CMPL BX, BP // i < n
RET
// func subVW
_s
(z, x *Word, y Word, n int) (c Word)
TEXT ·subVW
_s
(SB),7,$0
// func subVW(z, x *Word, y Word, n int) (c Word)
TEXT ·subVW(SB),7,$0
MOVL z+0(FP), DI
MOVL x+4(FP), SI
MOVL y+8(FP), AX // c = y
...
...
@@ -99,8 +99,8 @@ E4: CMPL BX, BP // i < n
RET
// func mulAddVWW
_s
(z, x *Word, y, r Word, n int) (c Word)
TEXT ·mulAddVWW
_s
(SB),7,$0
// func mulAddVWW(z, x *Word, y, r Word, n int) (c Word)
TEXT ·mulAddVWW(SB),7,$0
MOVL z+0(FP), DI
MOVL x+4(FP), SI
MOVL y+8(FP), BP
...
...
@@ -126,8 +126,8 @@ E5: CMPL BX, $0 // i < 0
RET
// func addMulVVW
_s
(z, x *Word, y Word, n int) (c Word)
TEXT ·addMulVVW
_s
(SB),7,$0
// func addMulVVW(z, x *Word, y Word, n int) (c Word)
TEXT ·addMulVVW(SB),7,$0
MOVL z+0(FP), DI
MOVL x+4(FP), SI
MOVL y+8(FP), BP
...
...
@@ -155,8 +155,8 @@ E6: CMPL BX, $0 // i < 0
RET
// divWVW
_s
(z* Word, xn Word, x *Word, y Word, n int) (r Word)
TEXT ·divWVW
_s
(SB),7,$0
// divWVW(z* Word, xn Word, x *Word, y Word, n int) (r Word)
TEXT ·divWVW(SB),7,$0
MOVL z+0(FP), DI
MOVL xn+4(FP), DX // r = xn
MOVL x+8(FP), SI
...
...
src/pkg/big/arith_amd64.s
View file @
73374c93
...
...
@@ -7,8 +7,8 @@
// TODO(gri) - experiment with unrolled loops for faster execution
// func addVV
_s
(z, x, y *Word, n int) (c Word)
TEXT ·addVV
_s
(SB),7,$0
// func addVV(z, x, y *Word, n int) (c Word)
TEXT ·addVV(SB),7,$0
MOVQ z+0(FP), R10
MOVQ x+8(FP), R8
MOVQ y+16(FP), R9
...
...
@@ -31,9 +31,9 @@ E1: CMPQ BX, R11 // i < n
RET
// func subVV
_s
(z, x, y *Word, n int) (c Word)
// func subVV(z, x, y *Word, n int) (c Word)
// (same as addVV_s except for SBBQ instead of ADCQ and label names)
TEXT ·subVV
_s
(SB),7,$0
TEXT ·subVV(SB),7,$0
MOVQ z+0(FP), R10
MOVQ x+8(FP), R8
MOVQ y+16(FP), R9
...
...
@@ -56,8 +56,8 @@ E2: CMPQ BX, R11 // i < n
RET
// func addVW
_s
(z, x *Word, y Word, n int) (c Word)
TEXT ·addVW
_s
(SB),7,$0
// func addVW(z, x *Word, y Word, n int) (c Word)
TEXT ·addVW(SB),7,$0
MOVQ z+0(FP), R10
MOVQ x+8(FP), R8
MOVQ y+16(FP), AX // c = y
...
...
@@ -78,8 +78,8 @@ E3: CMPQ BX, R11 // i < n
RET
// func subVW
_s
(z, x *Word, y Word, n int) (c Word)
TEXT ·subVW
_s
(SB),7,$0
// func subVW(z, x *Word, y Word, n int) (c Word)
TEXT ·subVW(SB),7,$0
MOVQ z+0(FP), R10
MOVQ x+8(FP), R8
MOVQ y+16(FP), AX // c = y
...
...
@@ -101,8 +101,8 @@ E4: CMPQ BX, R11 // i < n
RET
// func mulAddVWW
_s
(z, x *Word, y, r Word, n int) (c Word)
TEXT ·mulAddVWW
_s
(SB),7,$0
// func mulAddVWW(z, x *Word, y, r Word, n int) (c Word)
TEXT ·mulAddVWW(SB),7,$0
MOVQ z+0(FP), R10
MOVQ x+8(FP), R8
MOVQ y+16(FP), R9
...
...
@@ -126,8 +126,8 @@ E5: CMPQ BX, R11 // i < n
RET
// func addMulVVW
_s
(z, x *Word, y Word, n int) (c Word)
TEXT ·addMulVVW
_s
(SB),7,$0
// func addMulVVW(z, x *Word, y Word, n int) (c Word)
TEXT ·addMulVVW(SB),7,$0
MOVQ z+0(FP), R10
MOVQ x+8(FP), R8
MOVQ y+16(FP), R9
...
...
@@ -153,8 +153,8 @@ E6: CMPQ BX, R11 // i < n
RET
// divWVW
_s
(z* Word, xn Word, x *Word, y Word, n int) (r Word)
TEXT ·divWVW
_s
(SB),7,$0
// divWVW(z* Word, xn Word, x *Word, y Word, n int) (r Word)
TEXT ·divWVW(SB),7,$0
MOVQ z+0(FP), R10
MOVQ xn+8(FP), DX // r = xn
MOVQ x+16(FP), R8
...
...
src/pkg/big/arith_arm.s
View file @
73374c93
...
...
@@ -6,24 +6,24 @@
// arithmetic operations on vectors implemented in arith.go.
// TODO(gri) Implement these routines.
TEXT ·addVV
_s
(SB),7,$0
TEXT ·addVV(SB),7,$0
B ·addVV_g(SB)
TEXT ·subVV
_s
(SB),7,$0
TEXT ·subVV(SB),7,$0
B ·subVV_g(SB)
TEXT ·addVW
_s
(SB),7,$0
TEXT ·addVW(SB),7,$0
B ·addVW_g(SB)
TEXT ·subVW
_s
(SB),7,$0
TEXT ·subVW(SB),7,$0
B ·subVW_g(SB)
TEXT ·mulAddVWW
_s
(SB),7,$0
TEXT ·mulAddVWW(SB),7,$0
B ·mulAddVWW_g(SB)
TEXT ·addMulVVW
_s
(SB),7,$0
TEXT ·addMulVVW(SB),7,$0
B ·addMulVVW_g(SB)
TEXT ·divWVW
_s
(SB),7,$0
TEXT ·divWVW(SB),7,$0
B ·divWVW_g(SB)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment