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
76a763e0
Commit
76a763e0
authored
Aug 07, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
8 shift bug
R=ken OCL=32882 CL=32882
parent
c30d81bd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
ggen.c
src/cmd/8g/ggen.c
+28
-1
No files found.
src/cmd/8g/ggen.c
View file @
76a763e0
...
@@ -499,6 +499,18 @@ ret:
...
@@ -499,6 +499,18 @@ ret:
;
;
}
}
int
samereg
(
Node
*
a
,
Node
*
b
)
{
if
(
a
->
op
!=
OREGISTER
)
return
0
;
if
(
b
->
op
!=
OREGISTER
)
return
0
;
if
(
a
->
val
.
u
.
reg
!=
b
->
val
.
u
.
reg
)
return
0
;
return
1
;
}
/*
/*
* generate division.
* generate division.
* caller must set:
* caller must set:
...
@@ -581,7 +593,7 @@ cgen_div(int op, Node *nl, Node *nr, Node *res)
...
@@ -581,7 +593,7 @@ cgen_div(int op, Node *nl, Node *nr, Node *res)
void
void
cgen_shift
(
int
op
,
Node
*
nl
,
Node
*
nr
,
Node
*
res
)
cgen_shift
(
int
op
,
Node
*
nl
,
Node
*
nr
,
Node
*
res
)
{
{
Node
n1
,
n2
;
Node
n1
,
n2
,
cx
,
oldcx
;
int
a
,
w
;
int
a
,
w
;
Prog
*
p1
;
Prog
*
p1
;
uvlong
sc
;
uvlong
sc
;
...
@@ -611,9 +623,19 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
...
@@ -611,9 +623,19 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
return
;
return
;
}
}
memset
(
&
oldcx
,
0
,
sizeof
oldcx
);
nodreg
(
&
cx
,
types
[
TUINT32
],
D_CX
);
if
(
reg
[
D_CX
]
>
0
&&
!
samereg
(
&
cx
,
res
))
{
regalloc
(
&
oldcx
,
types
[
TUINT32
],
N
);
gmove
(
&
cx
,
&
oldcx
);
}
nodreg
(
&
n1
,
types
[
TUINT32
],
D_CX
);
nodreg
(
&
n1
,
types
[
TUINT32
],
D_CX
);
regalloc
(
&
n1
,
nr
->
type
,
&
n1
);
// to hold the shift type in CX
regalloc
(
&
n1
,
nr
->
type
,
&
n1
);
// to hold the shift type in CX
if
(
samereg
(
&
cx
,
res
))
regalloc
(
&
n2
,
nl
->
type
,
N
);
else
regalloc
(
&
n2
,
nl
->
type
,
res
);
regalloc
(
&
n2
,
nl
->
type
,
res
);
if
(
nl
->
ullman
>=
nr
->
ullman
)
{
if
(
nl
->
ullman
>=
nr
->
ullman
)
{
cgen
(
nl
,
&
n2
);
cgen
(
nl
,
&
n2
);
...
@@ -634,6 +656,11 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
...
@@ -634,6 +656,11 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
patch
(
p1
,
pc
);
patch
(
p1
,
pc
);
gins
(
a
,
&
n1
,
&
n2
);
gins
(
a
,
&
n1
,
&
n2
);
if
(
oldcx
.
op
!=
0
)
{
gmove
(
&
oldcx
,
&
cx
);
regfree
(
&
oldcx
);
}
gmove
(
&
n2
,
res
);
gmove
(
&
n2
,
res
);
regfree
(
&
n1
);
regfree
(
&
n1
);
...
...
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