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
07044ba6
Commit
07044ba6
authored
Aug 08, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plateau in divide by a constant
still to do - overflow, mod R=rsc OCL=32927 CL=32927
parent
8b8a2bd9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
ggen.c
src/cmd/6g/ggen.c
+24
-3
gsubr.c
src/cmd/6g/gsubr.c
+28
-4
go.h
src/cmd/gc/go.h
+1
-1
No files found.
src/cmd/6g/ggen.c
View file @
07044ba6
...
...
@@ -657,7 +657,6 @@ cgen_div(int op, Node *nl, Node *nr, Node *res)
return
;
divbymul:
goto
longdiv
;
switch
(
simtype
[
nl
->
type
->
etype
])
{
default:
goto
longdiv
;
...
...
@@ -678,7 +677,29 @@ goto longdiv;
// todo fixup
break
;
}
break
;
savex
(
D_AX
,
&
ax
,
&
oldax
,
res
,
nl
->
type
);
savex
(
D_DX
,
&
dx
,
&
olddx
,
res
,
nl
->
type
);
savex
(
D_CX
,
&
cx
,
&
oldcx
,
res
,
nl
->
type
);
regalloc
(
&
n1
,
nl
->
type
,
N
);
cgen
(
nl
,
&
n1
);
// num -> reg(n1)
nodconst
(
&
n2
,
nl
->
type
,
m
.
um
);
gmove
(
&
n2
,
&
ax
);
// const->ax
gins
(
optoas
(
OHMUL
,
nl
->
type
),
&
n1
,
N
);
// imul reg
nodconst
(
&
n2
,
nl
->
type
,
m
.
s
);
gins
(
optoas
(
ORSH
,
nl
->
type
),
&
n2
,
&
dx
);
// shift dx
regfree
(
&
n1
);
gmove
(
&
dx
,
res
);
restx
(
&
ax
,
&
oldax
);
restx
(
&
dx
,
&
olddx
);
restx
(
&
cx
,
&
oldcx
);
return
;
case
TINT16
:
case
TINT32
:
...
...
@@ -707,7 +728,7 @@ goto longdiv;
nodconst
(
&
n2
,
nl
->
type
,
m
.
sm
);
gmove
(
&
n2
,
&
ax
);
// const->ax
gins
(
optoas
(
OMUL
,
nl
->
type
),
&
n1
,
N
);
// imul reg
gins
(
optoas
(
O
H
MUL
,
nl
->
type
),
&
n1
,
N
);
// imul reg
nodconst
(
&
n2
,
nl
->
type
,
m
.
s
);
gins
(
optoas
(
ORSH
,
nl
->
type
),
&
n2
,
&
dx
);
// shift dx
...
...
src/cmd/6g/gsubr.c
View file @
07044ba6
...
...
@@ -1473,28 +1473,50 @@ optoas(int op, Type *t)
a
=
ASARQ
;
break
;
case
CASE
(
OHMUL
,
TINT8
):
case
CASE
(
OMUL
,
TINT8
):
case
CASE
(
OMUL
,
TUINT8
):
a
=
AIMULB
;
break
;
case
CASE
(
OHMUL
,
TINT16
):
case
CASE
(
OMUL
,
TINT16
):
case
CASE
(
OMUL
,
TUINT16
):
a
=
AIMULW
;
break
;
case
CASE
(
OHMUL
,
TINT32
):
case
CASE
(
OMUL
,
TINT32
):
case
CASE
(
OMUL
,
TUINT32
):
case
CASE
(
OMUL
,
TPTR32
):
a
=
AIMULL
;
break
;
case
CASE
(
OHMUL
,
TINT64
):
case
CASE
(
OMUL
,
TINT64
):
case
CASE
(
OMUL
,
TUINT64
):
case
CASE
(
OMUL
,
TPTR64
):
a
=
AIMULQ
;
break
;
case
CASE
(
OHMUL
,
TUINT8
):
a
=
AMULB
;
break
;
case
CASE
(
OHMUL
,
TUINT16
):
a
=
AMULW
;
break
;
case
CASE
(
OHMUL
,
TUINT32
):
case
CASE
(
OHMUL
,
TPTR32
):
a
=
AMULL
;
break
;
case
CASE
(
OHMUL
,
TUINT64
):
case
CASE
(
OHMUL
,
TPTR64
):
a
=
AMULQ
;
break
;
case
CASE
(
OMUL
,
TFLOAT32
):
a
=
AMULSS
;
break
;
...
...
@@ -1930,8 +1952,8 @@ void
smagic
(
Magic
*
m
)
{
int
p
;
uint64
ad
,
anc
,
delta
,
q1
,
r1
,
q2
,
r2
,
t
,
two31
;
uint64
mask
;
uint64
ad
,
anc
,
delta
,
q1
,
r1
,
q2
,
r2
,
t
;
uint64
mask
,
two31
;
m
->
bad
=
0
;
switch
(
m
->
w
)
{
...
...
@@ -2013,6 +2035,8 @@ smagic(Magic *m)
}
m
->
sm
=
q2
+
1
;
if
(
m
->
sm
&
two31
)
m
->
sm
|=
~
mask
;
m
->
s
=
p
-
m
->
w
;
}
...
...
@@ -2020,8 +2044,8 @@ void
umagic
(
Magic
*
m
)
{
int
p
;
uint64
nc
,
delta
,
q1
,
r1
,
q2
,
r2
,
two31
;
uint64
mask
;
uint64
nc
,
delta
,
q1
,
r1
,
q2
,
r2
;
uint64
mask
,
two31
;
m
->
bad
=
0
;
m
->
ua
=
0
;
...
...
src/cmd/gc/go.h
View file @
07044ba6
...
...
@@ -343,7 +343,7 @@ enum
OKEY
,
OPARAM
,
OLEN
,
OMAKE
,
OMAKECHAN
,
OMAKEMAP
,
OMAKESLICE
,
OMUL
,
ODIV
,
OMOD
,
OLSH
,
ORSH
,
OAND
,
OANDNOT
,
OMUL
,
ODIV
,
OMOD
,
OLSH
,
ORSH
,
O
HMUL
,
O
AND
,
OANDNOT
,
ONEW
,
ONOT
,
OCOM
,
OPLUS
,
OMINUS
,
OOROR
,
...
...
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