Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
b71c484c
Commit
b71c484c
authored
Sep 30, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 386 build - register allocation and shift bug
R=ken OCL=35140 CL=35142
parent
e7f9452d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
src/cmd/8g/cgen.c
src/cmd/8g/cgen.c
+19
-9
src/cmd/8g/ggen.c
src/cmd/8g/ggen.c
+4
-4
No files found.
src/cmd/8g/cgen.c
View file @
b71c484c
...
@@ -47,7 +47,7 @@ mfree(Node *n)
...
@@ -47,7 +47,7 @@ mfree(Node *n)
void
void
cgen
(
Node
*
n
,
Node
*
res
)
cgen
(
Node
*
n
,
Node
*
res
)
{
{
Node
*
nl
,
*
nr
,
*
r
,
n1
,
n2
,
f0
,
f1
;
Node
*
nl
,
*
nr
,
*
r
,
n1
,
n2
,
nt
,
f0
,
f1
;
Prog
*
p1
,
*
p2
,
*
p3
;
Prog
*
p1
,
*
p2
,
*
p3
;
int
a
;
int
a
;
...
@@ -136,7 +136,7 @@ cgen(Node *n, Node *res)
...
@@ -136,7 +136,7 @@ cgen(Node *n, Node *res)
tempfree
(
&
n1
);
tempfree
(
&
n1
);
return
;
return
;
}
}
// 64-bit ops are hard on 32-bit machine.
// 64-bit ops are hard on 32-bit machine.
if
(
is64
(
n
->
type
)
||
is64
(
res
->
type
)
||
n
->
left
!=
N
&&
is64
(
n
->
left
->
type
))
{
if
(
is64
(
n
->
type
)
||
is64
(
res
->
type
)
||
n
->
left
!=
N
&&
is64
(
n
->
left
->
type
))
{
switch
(
n
->
op
)
{
switch
(
n
->
op
)
{
...
@@ -350,13 +350,16 @@ sbop: // symmetric binary
...
@@ -350,13 +350,16 @@ sbop: // symmetric binary
abop:
// asymmetric binary
abop:
// asymmetric binary
if
(
nl
->
ullman
>=
nr
->
ullman
)
{
if
(
nl
->
ullman
>=
nr
->
ullman
)
{
regalloc
(
&
n1
,
nl
->
type
,
res
);
tempalloc
(
&
nt
,
nl
->
type
);
cgen
(
nl
,
&
n
1
);
cgen
(
nl
,
&
n
t
);
mgen
(
nr
,
&
n2
,
N
);
mgen
(
nr
,
&
n2
,
N
);
regalloc
(
&
n1
,
nl
->
type
,
res
);
gmove
(
&
nt
,
&
n1
);
gins
(
a
,
&
n2
,
&
n1
);
gins
(
a
,
&
n2
,
&
n1
);
gmove
(
&
n1
,
res
);
gmove
(
&
n1
,
res
);
mfree
(
&
n2
);
regfree
(
&
n1
);
regfree
(
&
n1
);
mfree
(
&
n2
);
tempfree
(
&
nt
);
}
else
{
}
else
{
regalloc
(
&
n2
,
nr
->
type
,
res
);
regalloc
(
&
n2
,
nr
->
type
,
res
);
cgen
(
nr
,
&
n2
);
cgen
(
nr
,
&
n2
);
...
@@ -529,7 +532,8 @@ agen(Node *n, Node *res)
...
@@ -529,7 +532,8 @@ agen(Node *n, Node *res)
nodconst
(
&
n2
,
types
[
TUINT32
],
v
);
nodconst
(
&
n2
,
types
[
TUINT32
],
v
);
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]),
&
n1
,
&
n2
);
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]),
&
n1
,
&
n2
);
p1
=
gbranch
(
optoas
(
OGT
,
types
[
TUINT32
]),
T
);
p1
=
gbranch
(
optoas
(
OGT
,
types
[
TUINT32
]),
T
);
ginscall
(
throwindex
,
0
);
//ginscall(throwindex, 0);
gins
(
AINT
,
nodintconst
(
3
),
N
);
patch
(
p1
,
pc
);
patch
(
p1
,
pc
);
}
}
...
@@ -575,7 +579,8 @@ agen(Node *n, Node *res)
...
@@ -575,7 +579,8 @@ agen(Node *n, Node *res)
nodconst
(
&
n1
,
types
[
TUINT32
],
nl
->
type
->
bound
);
nodconst
(
&
n1
,
types
[
TUINT32
],
nl
->
type
->
bound
);
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]),
&
n2
,
&
n1
);
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]),
&
n2
,
&
n1
);
p1
=
gbranch
(
optoas
(
OLT
,
types
[
TUINT32
]),
T
);
p1
=
gbranch
(
optoas
(
OLT
,
types
[
TUINT32
]),
T
);
ginscall
(
throwindex
,
0
);
//ginscall(throwindex, 0);
gins
(
AINT
,
nodintconst
(
3
),
N
);
patch
(
p1
,
pc
);
patch
(
p1
,
pc
);
}
}
...
@@ -661,8 +666,13 @@ agen(Node *n, Node *res)
...
@@ -661,8 +666,13 @@ agen(Node *n, Node *res)
void
void
igen
(
Node
*
n
,
Node
*
a
,
Node
*
res
)
igen
(
Node
*
n
,
Node
*
a
,
Node
*
res
)
{
{
Node
n1
;
tempalloc
(
&
n1
,
types
[
tptr
]);
agen
(
n
,
&
n1
);
regalloc
(
a
,
types
[
tptr
],
res
);
regalloc
(
a
,
types
[
tptr
],
res
);
agen
(
n
,
a
);
gmove
(
&
n1
,
a
);
tempfree
(
&
n1
);
a
->
op
=
OINDREG
;
a
->
op
=
OINDREG
;
a
->
type
=
n
->
type
;
a
->
type
=
n
->
type
;
}
}
...
@@ -834,7 +844,7 @@ bgen(Node *n, int true, Prog *to)
...
@@ -834,7 +844,7 @@ bgen(Node *n, int true, Prog *to)
regfree
(
&
n1
);
regfree
(
&
n1
);
break
;
break
;
}
}
if
(
isinter
(
nl
->
type
))
{
if
(
isinter
(
nl
->
type
))
{
// front end shold only leave cmp to literal nil
// front end shold only leave cmp to literal nil
if
((
a
!=
OEQ
&&
a
!=
ONE
)
||
nr
->
op
!=
OLITERAL
)
{
if
((
a
!=
OEQ
&&
a
!=
ONE
)
||
nr
->
op
!=
OLITERAL
)
{
...
...
src/cmd/8g/ggen.c
View file @
b71c484c
...
@@ -650,8 +650,8 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
...
@@ -650,8 +650,8 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
memset
(
&
oldcx
,
0
,
sizeof
oldcx
);
memset
(
&
oldcx
,
0
,
sizeof
oldcx
);
nodreg
(
&
cx
,
types
[
TUINT32
],
D_CX
);
nodreg
(
&
cx
,
types
[
TUINT32
],
D_CX
);
if
(
reg
[
D_CX
]
>
0
&&
!
samereg
(
&
cx
,
res
))
{
if
(
reg
[
D_CX
]
>
1
&&
!
samereg
(
&
cx
,
res
))
{
regalloc
(
&
oldcx
,
types
[
TUINT32
],
N
);
tempalloc
(
&
oldcx
,
types
[
TUINT32
]
);
gmove
(
&
cx
,
&
oldcx
);
gmove
(
&
cx
,
&
oldcx
);
}
}
...
@@ -671,7 +671,7 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
...
@@ -671,7 +671,7 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
}
}
// test and fix up large shifts
// test and fix up large shifts
gins
(
optoas
(
OCMP
,
types
[
TUINT32
]
),
&
n1
,
ncon
(
w
));
gins
(
optoas
(
OCMP
,
nr
->
type
),
&
n1
,
ncon
(
w
));
p1
=
gbranch
(
optoas
(
OLT
,
types
[
TUINT32
]),
T
);
p1
=
gbranch
(
optoas
(
OLT
,
types
[
TUINT32
]),
T
);
if
(
op
==
ORSH
&&
issigned
[
nl
->
type
->
etype
])
{
if
(
op
==
ORSH
&&
issigned
[
nl
->
type
->
etype
])
{
gins
(
a
,
ncon
(
w
-
1
),
&
n2
);
gins
(
a
,
ncon
(
w
-
1
),
&
n2
);
...
@@ -683,7 +683,7 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
...
@@ -683,7 +683,7 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
if
(
oldcx
.
op
!=
0
)
{
if
(
oldcx
.
op
!=
0
)
{
gmove
(
&
oldcx
,
&
cx
);
gmove
(
&
oldcx
,
&
cx
);
reg
free
(
&
oldcx
);
temp
free
(
&
oldcx
);
}
}
gmove
(
&
n2
,
res
);
gmove
(
&
n2
,
res
);
...
...
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