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
c00f9f49
Commit
c00f9f49
authored
Oct 20, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6g: avoid too-large immediate constants
R=ken2 CC=golang-dev
https://golang.org/cl/2566042
parent
97f3a80d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
26 deletions
+37
-26
src/cmd/6g/cgen.c
src/cmd/6g/cgen.c
+7
-15
src/cmd/6g/gg.h
src/cmd/6g/gg.h
+1
-0
src/cmd/6g/ggen.c
src/cmd/6g/ggen.c
+4
-8
src/cmd/6g/gsubr.c
src/cmd/6g/gsubr.c
+25
-3
No files found.
src/cmd/6g/cgen.c
View file @
c00f9f49
...
...
@@ -537,9 +537,7 @@ agen(Node *n, Node *res)
gmove
(
&
n1
,
&
n3
);
}
nodconst
(
&
n2
,
types
[
tptr
],
v
*
w
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n2
,
&
n3
);
ginscon
(
optoas
(
OADD
,
types
[
tptr
]),
v
*
w
,
&
n3
);
gmove
(
&
n3
,
res
);
regfree
(
&
n3
);
break
;
...
...
@@ -596,8 +594,7 @@ agen(Node *n, Node *res)
p1
->
from
.
index
=
p1
->
from
.
type
;
p1
->
from
.
type
=
p1
->
to
.
type
+
D_INDIR
;
}
else
{
nodconst
(
&
n1
,
t
,
w
);
gins
(
optoas
(
OMUL
,
t
),
&
n1
,
&
n2
);
ginscon
(
optoas
(
OMUL
,
t
),
w
,
&
n2
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n2
,
&
n3
);
gmove
(
&
n3
,
res
);
}
...
...
@@ -621,10 +618,8 @@ agen(Node *n, Node *res)
fatal
(
"agen: bad ONAME class %#x"
,
n
->
class
);
}
cgen
(
n
->
heapaddr
,
res
);
if
(
n
->
xoffset
!=
0
)
{
nodconst
(
&
n1
,
types
[
TINT64
],
n
->
xoffset
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n1
,
res
);
}
if
(
n
->
xoffset
!=
0
)
ginscon
(
optoas
(
OADD
,
types
[
tptr
]),
n
->
xoffset
,
res
);
break
;
case
OIND
:
...
...
@@ -633,10 +628,8 @@ agen(Node *n, Node *res)
case
ODOT
:
agen
(
nl
,
res
);
if
(
n
->
xoffset
!=
0
)
{
nodconst
(
&
n1
,
types
[
TINT64
],
n
->
xoffset
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n1
,
res
);
}
if
(
n
->
xoffset
!=
0
)
ginscon
(
optoas
(
OADD
,
types
[
tptr
]),
n
->
xoffset
,
res
);
break
;
case
ODOTPTR
:
...
...
@@ -653,8 +646,7 @@ agen(Node *n, Node *res)
gins
(
ATESTB
,
nodintconst
(
0
),
&
n1
);
regfree
(
&
n1
);
}
nodconst
(
&
n1
,
types
[
TINT64
],
n
->
xoffset
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n1
,
res
);
ginscon
(
optoas
(
OADD
,
types
[
tptr
]),
n
->
xoffset
,
res
);
}
break
;
}
...
...
src/cmd/6g/gg.h
View file @
c00f9f49
...
...
@@ -123,6 +123,7 @@ Node* nodarg(Type*, int);
void
nodreg
(
Node
*
,
Type
*
,
int
);
void
nodindreg
(
Node
*
,
Type
*
,
int
);
void
gconreg
(
int
,
vlong
,
int
);
void
ginscon
(
int
,
vlong
,
Node
*
);
void
buildtxt
(
void
);
Plist
*
newplist
(
void
);
int
isfat
(
Type
*
);
...
...
src/cmd/6g/ggen.c
View file @
c00f9f49
...
...
@@ -1292,10 +1292,8 @@ slicearray:
if
(
smallintconst
(
&
nodes
[
2
])
&&
smallintconst
(
&
nodes
[
4
]))
{
v
=
mpgetfix
(
nodes
[
2
].
val
.
u
.
xval
)
*
mpgetfix
(
nodes
[
4
].
val
.
u
.
xval
);
if
(
v
!=
0
)
{
nodconst
(
&
n1
,
types
[
tptr
],
v
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n1
,
&
nodes
[
0
]);
}
if
(
v
!=
0
)
ginscon
(
optoas
(
OADD
,
types
[
tptr
]),
v
,
&
nodes
[
0
]);
}
else
{
regalloc
(
&
n1
,
types
[
tptr
],
&
nodes
[
2
]);
gmove
(
&
nodes
[
2
],
&
n1
);
...
...
@@ -1409,10 +1407,8 @@ sliceslice:
gins
(
optoas
(
OAS
,
types
[
tptr
]),
&
n2
,
&
n1
);
v
=
mpgetfix
(
nodes
[
1
].
val
.
u
.
xval
)
*
mpgetfix
(
nodes
[
3
].
val
.
u
.
xval
);
if
(
v
!=
0
)
{
nodconst
(
&
n2
,
types
[
tptr
],
v
);
gins
(
optoas
(
OADD
,
types
[
tptr
]),
&
n2
,
&
n1
);
}
if
(
v
!=
0
)
ginscon
(
optoas
(
OADD
,
types
[
tptr
]),
v
,
&
n1
);
}
else
{
gmove
(
&
nodes
[
1
],
&
n1
);
if
(
!
smallintconst
(
&
nodes
[
3
])
||
mpgetfix
(
nodes
[
3
].
val
.
u
.
xval
)
!=
1
)
...
...
src/cmd/6g/gsubr.c
View file @
c00f9f49
...
...
@@ -430,11 +430,33 @@ fatal("shouldnt be used");
void
gconreg
(
int
as
,
vlong
c
,
int
reg
)
{
Node
n1
,
n2
;
Node
nr
;
nodreg
(
&
nr
,
types
[
TINT64
],
reg
);
ginscon
(
as
,
c
,
&
nr
);
}
/*
* generate
* as $c, n
*/
void
ginscon
(
int
as
,
vlong
c
,
Node
*
n2
)
{
Node
n1
,
ntmp
;
nodconst
(
&
n1
,
types
[
TINT64
],
c
);
nodreg
(
&
n2
,
types
[
TINT64
],
reg
);
gins
(
as
,
&
n1
,
&
n2
);
if
(
as
!=
AMOVQ
&&
(
c
<
-
1LL
<<
31
||
c
>=
1LL
<<
31
))
{
// cannot have 64-bit immediokate in ADD, etc.
// instead, MOV into register first.
regalloc
(
&
ntmp
,
types
[
TINT64
],
N
);
gins
(
AMOVQ
,
&
n1
,
&
ntmp
);
gins
(
as
,
&
ntmp
,
n2
);
regfree
(
&
ntmp
);
return
;
}
gins
(
as
,
&
n1
,
n2
);
}
#define CASE(a,b) (((a)<<16)|((b)<<0))
...
...
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