1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:20:11 -07:00

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
This commit is contained in:
Elias Naur 2013-02-01 08:35:33 -08:00 committed by Russ Cox
parent b0a29f393b
commit fe14ee52cc
9 changed files with 34 additions and 6 deletions

View File

@ -126,7 +126,10 @@ xcom(Node *n)
break;
case ONAME:
n->addable = 10;
if(flag_largemodel)
n->addable = 9;
else
n->addable = 10;
if(n->class == CPARAM || n->class == CAUTO)
n->addable = 11;
break;

View File

@ -737,8 +737,12 @@ agenr(Node *n, Node *a, Node *res)
regalloc(&n3, types[tptr], res);
p1 = gins(ALEAQ, N, &n3);
datastring(nl->val.u.sval->s, nl->val.u.sval->len, &p1->from);
p1->from.scale = 1;
p1->from.index = n2.val.u.reg;
if(flag_largemodel) {
gins(AADDQ, &n2, &n3);
} else {
p1->from.scale = 1;
p1->from.index = n2.val.u.reg;
}
goto indexdone;
}

View File

@ -59,6 +59,7 @@ ginscall(Node *f, int proc)
{
Prog *p;
Node reg, con;
Node r1;
switch(proc) {
default:
@ -76,7 +77,14 @@ ginscall(Node *f, int proc)
case 1: // call in new proc (go)
case 2: // deferred call (defer)
nodreg(&reg, types[TINT64], D_CX);
gins(APUSHQ, f, N);
if(flag_largemodel) {
regalloc(&r1, f->type, f);
gmove(f, &r1);
gins(APUSHQ, &r1, N);
regfree(&r1);
} else {
gins(APUSHQ, f, N);
}
nodconst(&con, types[TINT32], argsize(f->type));
gins(APUSHQ, &con, N);
if(proc == 1)

View File

@ -554,6 +554,10 @@ ismem(Node *n)
case ONAME:
case OPARAM:
return 1;
case OADDR:
if(flag_largemodel)
return 1;
break;
}
return 0;
}

View File

@ -528,6 +528,7 @@ EXTERN int packflg;
EXTERN int fproundflg;
EXTERN int textflag;
EXTERN int dataflag;
EXTERN int flag_largemodel;
EXTERN int ncontin;
EXTERN int canreach;
EXTERN int warnreach;

View File

@ -174,6 +174,8 @@ main(int argc, char *argv[])
flagcount("t", "debug code generation", &debug['t']);
flagcount("w", "enable warnings", &debug['w']);
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);

View File

@ -941,6 +941,7 @@ EXTERN int compiling_runtime;
EXTERN int compiling_wrappers;
EXTERN int pure_go;
EXTERN int flag_race;
EXTERN int flag_largemodel;
EXTERN int nointerface;
EXTERN int fieldtrack_enabled;

View File

@ -257,6 +257,8 @@ main(int argc, char *argv[])
flagcount("w", "debug type checking", &debug['w']);
flagcount("x", "debug lexer", &debug['x']);
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);

View File

@ -23,6 +23,9 @@
# GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
# 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
# to include all cgo related files, .c and .go file with "cgo"
# build directive, in the build. Set it to 0 to ignore them.
@ -129,12 +132,12 @@ echo
if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
echo "# Building packages and commands for host, $GOHOSTOS/$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
fi
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
rm -f "$GOTOOLDIR"/go_bootstrap