Commit fe14ee52 authored by Elias Naur's avatar Elias Naur Committed by Russ Cox

cmd/6c, cmd/6g: add flag to support large-model code generation

Added the -pic flag to 6c and 6g to avoid assembler instructions that
cannot use RIP-relative adressing. This is needed to support the -shared mode
in 6l.

See also:
https://golang.org/cl/6926049
https://golang.org/cl/6822078

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7064048
parent b0a29f39
...@@ -126,6 +126,9 @@ xcom(Node *n) ...@@ -126,6 +126,9 @@ xcom(Node *n)
break; break;
case ONAME: case ONAME:
if(flag_largemodel)
n->addable = 9;
else
n->addable = 10; n->addable = 10;
if(n->class == CPARAM || n->class == CAUTO) if(n->class == CPARAM || n->class == CAUTO)
n->addable = 11; n->addable = 11;
......
...@@ -737,8 +737,12 @@ agenr(Node *n, Node *a, Node *res) ...@@ -737,8 +737,12 @@ agenr(Node *n, Node *a, Node *res)
regalloc(&n3, types[tptr], res); regalloc(&n3, types[tptr], res);
p1 = gins(ALEAQ, N, &n3); p1 = gins(ALEAQ, N, &n3);
datastring(nl->val.u.sval->s, nl->val.u.sval->len, &p1->from); datastring(nl->val.u.sval->s, nl->val.u.sval->len, &p1->from);
if(flag_largemodel) {
gins(AADDQ, &n2, &n3);
} else {
p1->from.scale = 1; p1->from.scale = 1;
p1->from.index = n2.val.u.reg; p1->from.index = n2.val.u.reg;
}
goto indexdone; goto indexdone;
} }
......
...@@ -59,6 +59,7 @@ ginscall(Node *f, int proc) ...@@ -59,6 +59,7 @@ ginscall(Node *f, int proc)
{ {
Prog *p; Prog *p;
Node reg, con; Node reg, con;
Node r1;
switch(proc) { switch(proc) {
default: default:
...@@ -76,7 +77,14 @@ ginscall(Node *f, int proc) ...@@ -76,7 +77,14 @@ ginscall(Node *f, int proc)
case 1: // call in new proc (go) case 1: // call in new proc (go)
case 2: // deferred call (defer) case 2: // deferred call (defer)
nodreg(&reg, types[TINT64], D_CX); nodreg(&reg, types[TINT64], D_CX);
if(flag_largemodel) {
regalloc(&r1, f->type, f);
gmove(f, &r1);
gins(APUSHQ, &r1, N);
regfree(&r1);
} else {
gins(APUSHQ, f, N); gins(APUSHQ, f, N);
}
nodconst(&con, types[TINT32], argsize(f->type)); nodconst(&con, types[TINT32], argsize(f->type));
gins(APUSHQ, &con, N); gins(APUSHQ, &con, N);
if(proc == 1) if(proc == 1)
......
...@@ -554,6 +554,10 @@ ismem(Node *n) ...@@ -554,6 +554,10 @@ ismem(Node *n)
case ONAME: case ONAME:
case OPARAM: case OPARAM:
return 1; return 1;
case OADDR:
if(flag_largemodel)
return 1;
break;
} }
return 0; return 0;
} }
......
...@@ -528,6 +528,7 @@ EXTERN int packflg; ...@@ -528,6 +528,7 @@ EXTERN int packflg;
EXTERN int fproundflg; EXTERN int fproundflg;
EXTERN int textflag; EXTERN int textflag;
EXTERN int dataflag; EXTERN int dataflag;
EXTERN int flag_largemodel;
EXTERN int ncontin; EXTERN int ncontin;
EXTERN int canreach; EXTERN int canreach;
EXTERN int warnreach; EXTERN int warnreach;
......
...@@ -174,6 +174,8 @@ main(int argc, char *argv[]) ...@@ -174,6 +174,8 @@ main(int argc, char *argv[])
flagcount("t", "debug code generation", &debug['t']); flagcount("t", "debug code generation", &debug['t']);
flagcount("w", "enable warnings", &debug['w']); flagcount("w", "enable warnings", &debug['w']);
flagcount("v", "increase debug verbosity", &debug['v']); flagcount("v", "increase debug verbosity", &debug['v']);
if(thechar == '6')
flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel);
flagparse(&argc, &argv, usage); flagparse(&argc, &argv, usage);
......
...@@ -941,6 +941,7 @@ EXTERN int compiling_runtime; ...@@ -941,6 +941,7 @@ EXTERN int compiling_runtime;
EXTERN int compiling_wrappers; EXTERN int compiling_wrappers;
EXTERN int pure_go; EXTERN int pure_go;
EXTERN int flag_race; EXTERN int flag_race;
EXTERN int flag_largemodel;
EXTERN int nointerface; EXTERN int nointerface;
EXTERN int fieldtrack_enabled; EXTERN int fieldtrack_enabled;
......
...@@ -257,6 +257,8 @@ main(int argc, char *argv[]) ...@@ -257,6 +257,8 @@ main(int argc, char *argv[])
flagcount("w", "debug type checking", &debug['w']); flagcount("w", "debug type checking", &debug['w']);
flagcount("x", "debug lexer", &debug['x']); flagcount("x", "debug lexer", &debug['x']);
flagcount("y", "debug declarations in canned imports (with -d)", &debug['y']); flagcount("y", "debug declarations in canned imports (with -d)", &debug['y']);
if(thechar == '6')
flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel);
flagparse(&argc, &argv, usage); flagparse(&argc, &argv, usage);
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
# GO_LDFLAGS: Additional 5l/6l/8l arguments to use when # GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
# building the commands. # building the commands.
# #
# GO_CCFLAGS: Additional 5c/6c/8c arguments to use when
# building.
#
# CGO_ENABLED: Controls cgo usage during the build. Set it to 1 # CGO_ENABLED: Controls cgo usage during the build. Set it to 1
# to include all cgo related files, .c and .go file with "cgo" # to include all cgo related files, .c and .go file with "cgo"
# build directive, in the build. Set it to 0 to ignore them. # build directive, in the build. Set it to 0 to ignore them.
...@@ -129,12 +132,12 @@ echo ...@@ -129,12 +132,12 @@ echo
if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
echo "# Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH." echo "# Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH."
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \ GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
"$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std "$GOTOOLDIR"/go_bootstrap install -ccflags "$GO_CCFLAGS" -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std
echo echo
fi fi
echo "# Building packages and commands for $GOOS/$GOARCH." echo "# Building packages and commands for $GOOS/$GOARCH."
"$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -ccflags "$GO_CCFLAGS" -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std
echo echo
rm -f "$GOTOOLDIR"/go_bootstrap rm -f "$GOTOOLDIR"/go_bootstrap
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment