1
0
mirror of https://github.com/golang/go synced 2024-10-03 11:21:22 -06:00
Commit Graph

66 Commits

Author SHA1 Message Date
Elias Naur
fe14ee52cc 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
2013-02-01 08:35:33 -08:00
Anthony Martin
60826e0be6 cmd/6c, cmd/8c: fix print format for Prog
The FmtLong flag should only be used with the %D verb
when printing an ATEXT Prog. It was erroneously used
for every Prog except ADATA. This caused a preponderance
of exclamation points, "!!", in the assembly listings.

I also cleaned up the code so that the list.c files look
very similar. Now the real differences are easily spotted
with a simple diff.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7128045
2013-01-18 19:00:38 -08:00
Matthew Dempsky
bb192d1399 cmd/6c: Optimize rotate expressions to use rotate instructions.
For simplicity, only recognizes expressions of the exact form
"(x << a) | (x >> b)" where x is a variable and a and b are
integer constant expressions that add to x's bit width.

Fixes #4629.

$ cat rotate.c
unsigned int
rotate(unsigned int x)
{
        x = (x << 3) | (x >> (sizeof(x) * 8 - 3));
        return x;
}

## BEFORE
$ go tool 6c -S rotate.c
(rotate.c:2)	TEXT	rotate+0(SB),$0-8
(rotate.c:2)	MOVL	x+0(FP),!!DX
(rotate.c:4)	MOVL	DX,!!AX
(rotate.c:4)	SALL	$3,!!AX
(rotate.c:4)	MOVL	DX,!!CX
(rotate.c:4)	SHRL	$29,!!CX
(rotate.c:4)	ORL	CX,!!AX
(rotate.c:5)	RET	,!!
(rotate.c:5)	RET	,!!
(rotate.c:5)	END	,!!

## AFTER
$ go tool 6c -S rotate.c
(rotate.c:2)	TEXT	rotate+0(SB),$0-8
(rotate.c:4)	MOVL	x+0(FP),!!AX
(rotate.c:4)	ROLL	$3,!!AX
(rotate.c:5)	RET	,!!
(rotate.c:5)	RET	,!!
(rotate.c:5)	END	,!!

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7069056
2013-01-18 17:29:53 -05:00
Carl Shapiro
47568c747d cmd/5a, cmd/5c, cmd/6a, cmd/6c, cmd/8a, cmd/8c, cmd/ld: update reference
Reference the 80386 compiler documentation now that the
documentation for the 68020 is offline.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7127053
2013-01-18 13:39:53 -08:00
Matthew Dempsky
41ec481a53 cmd/6c: Improve peep hole optimization of rotate and shift instructions.
Update #4629.

$ cat shift2.c
unsigned int
shift(unsigned int x, unsigned int y)
{
        x = (x << 3);
        y = (y << 5);
        x = (x << 7);
        y = (y << 9);
        return x ^ y;
}

## BEFORE
$ go tool 6c -S shift2.c
(shift2.c:2)	TEXT	shift+0(SB),$0-8
(shift2.c:4)	MOVL	x+0(FP),!!AX
(shift2.c:4)	SALL	$3,!!AX
(shift2.c:4)	MOVL	AX,!!DX
(shift2.c:5)	MOVL	y+4(FP),!!AX
(shift2.c:5)	SALL	$5,!!AX
(shift2.c:5)	MOVL	AX,!!CX
(shift2.c:6)	MOVL	DX,!!AX
(shift2.c:6)	SALL	$7,!!AX
(shift2.c:6)	MOVL	AX,!!DX
(shift2.c:7)	MOVL	CX,!!AX
(shift2.c:7)	SALL	$9,!!AX
(shift2.c:7)	MOVL	AX,!!CX
(shift2.c:8)	MOVL	DX,!!AX
(shift2.c:8)	XORL	CX,!!AX
(shift2.c:8)	RET	,!!
(shift2.c:8)	RET	,!!
(shift2.c:8)	END	,!!

## AFTER
$ go tool 6c -S shift2.c
(shift2.c:2)	TEXT	shift+0(SB),$0-8
(shift2.c:4)	MOVL	x+0(FP),!!AX
(shift2.c:4)	SALL	$3,!!AX
(shift2.c:5)	MOVL	y+4(FP),!!CX
(shift2.c:5)	SALL	$5,!!CX
(shift2.c:6)	SALL	$7,!!AX
(shift2.c:7)	SALL	$9,!!CX
(shift2.c:8)	XORL	CX,!!AX
(shift2.c:8)	RET	,!!
(shift2.c:8)	RET	,!!
(shift2.c:8)	END	,!!

R=rsc, minux.ma, dave, nigeltao
CC=golang-dev
https://golang.org/cl/7066055
2013-01-18 16:33:25 -05:00
Rémy Oudompheng
5cb1ed2189 cmd/6c, cmd/8c: add fixjmp step to regopt.
The fixjmp step eliminates redundant chains of JMP
instructions that are produced by the compiler during
code generation.

It is already implemented in gc, and can be adapted to 6c/8c with
the exception that JMPs refer to destination by pc instead of by
pointer. The algorithm is modified to operate on Regs instead of Progs
for this reason. The pcs are already restored later by regopt.

R=goalng-dev, rsc
CC=golang-dev
https://golang.org/cl/6865046
2012-12-06 07:20:03 +01:00
Rémy Oudompheng
cc224c004d cmd/6c, cmd/8c: use signed char explicitly in mul.c
On ARM, char is unsigned, and the code generation for
multiplication gets totally broken.

Fixes #4354.

R=golang-dev, dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6826079
2012-11-09 21:06:45 +01:00
Rémy Oudompheng
33cceb09e2 cmd/{5g,6g,8g,6c}: remove unused macro, use %E to print etype.
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6569044
2012-09-24 23:44:00 +02:00
Shenghou Ma
dac4c3eee9 cmd/cgo, cmd/cc, cmd/ld: detect dynamic linker automatically
Some newer Linux distributions (Ubuntu ARM at least) use a new multiarch
directory organization, where dynamic linker is no longer in the hardcoded
path in our linker.
For example, Ubuntu 12.04 ARM hardfloat places its dynamic linker at
/lib/arm-linux-gnueabihf/ld-linux.so.3

Ref: http://lackof.org/taggart/hacking/multiarch/

Also, to support Debian GNU/kFreeBSD as a FreeBSD variant, we need this capability, so it's part of issue 3533.

This CL add a new pragma (#pragma dynlinker "path") to cc.

R=iant, rsc
CC=golang-dev
https://golang.org/cl/6086043
2012-05-05 01:54:16 +08:00
Russ Cox
d42495aa80 cmd/cc: add PREFETCH built-in (like SET, USED)
This makes it possible to inline the prefetch of upcoming
memory addresses during garbage collection, instead of
needing to flush registers, make a function call, and
reload registers.  On garbage collection-heavy workloads,
this results in a 5% speedup.

Fixes #3493.

R=dvyukov, ken, r, dave
CC=golang-dev
https://golang.org/cl/5990066
2012-05-02 16:22:56 -04:00
Russ Cox
e530d6a1e0 6c, 6g, 6l: add MOVQL to make truncation explicit
Without an explicit signal for a truncation, copy propagation
will sometimes propagate a 32-bit truncation and end up
overwriting uses of the original 64-bit value.

The case that arose in practice is in C but I believe
that the same could plausibly happen in Go.
The main reason we didn't run into the same in Go
is that I (perhaps incorrectly?) drop MOVL AX, AX
during gins, so the truncation was never generated, so
it didn't confuse the optimizer.

Fixes #1315.
Fixes #3488.

R=ken2
CC=golang-dev
https://golang.org/cl/6002043
2012-04-10 12:51:59 -04:00
Russ Cox
b72c7e943c cmd/6c: fix probable code gen bug
This is a pointer being copied; MOVL can't possibly be right.

R=ken2
CC=golang-dev
https://golang.org/cl/5999043
2012-04-10 12:51:36 -04:00
Shenghou Ma
bcdafaa582 5c, 6c, 8c: take GOROOT_FINAL into consideration
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5936050
2012-04-04 00:04:36 +08:00
Russ Cox
5bcad92f07 ld: add NOPTRBSS for large, pointer-free uninitialized data
cc: add #pragma textflag to set it
runtime: mark mheap to go into noptr-bss.
        remove special case in garbage collector

Remove the ARM from.flag field created by CL 5687044.
The DUPOK flag was already in p->reg, so keep using that.

Otherwise test/nilptr.go creates a very large binary.
Should fix the arm build.
Diagnosed by minux.ma; replacement for CL 5690044.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/5686060
2012-02-21 22:08:42 -05:00
Shenghou Ma
6ed2b6c47d 5c, 6c, 8c, 6g, 8g: correct boundary checking
CL 5666043 fixed the same checking for 5g.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5666045
2012-02-15 08:59:03 -05:00
Russ Cox
fec7fa8b9d build: delete make paraphernalia
As a convenience to people working on the tools,
leave Makefiles that invoke the go dist tool appropriately.
They are not used during the build.

R=golang-dev, bradfitz, n13m3y3r, gustavo
CC=golang-dev
https://golang.org/cl/5636050
2012-02-06 13:34:25 -05:00
Anthony Martin
e280035fc1 gc, cc: avoid using the wrong library when building the compilers
This can happen on Plan 9 if we we're building
with the 32-bit and 64-bit host compilers, one
after the other.

R=rsc
CC=golang-dev
https://golang.org/cl/5599053
2012-02-01 04:14:37 -08:00
Anthony Martin
6273d6e713 build: move the "-c" flag into HOST_CFLAGS
On Plan 9 this flag is used to discover
constant expressions in "if" statements.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5601060
2012-01-31 19:31:30 -08:00
Rob Pike
91cb3489ab go: move compilers into the go-tool directory
Also delete gotest, since it's messy to fix and slated for deletion anyway.
A couple of things outside src can't be tested any more. "go test" will be
fixed and these tests will be re-enabled. They're noisy for now.

Fixes #284.

R=rsc
CC=golang-dev
https://golang.org/cl/5598049
2012-01-30 14:46:31 -08:00
Russ Cox
109a976355 6c, 8c: make floating point code NaN-safe
R=ken2
CC=golang-dev
https://golang.org/cl/5569071
2012-01-26 16:23:29 -05:00
Anthony Martin
d89b7173c2 5c, 6c, 8c: support 64-bit switch value
For real this time. :-)

R=rsc, ken
CC=golang-dev
https://golang.org/cl/5486061
2011-12-14 17:30:40 -05:00
Ron Minnich
1bc1caa802 cc: change cas to newcase
Change the name of cas() in cc to newcase() to avoid a NIX conflict.
cas() is used in cc to create a new Case struct. There is a name
conflict in that cas() is a commonly-used
name for compare and swap. Since cas() is only used internally
in the compiler in 3 places, change the name to avoid a wider
conflict with the NIX runtime. This issue might well come up on
other OSes in the future anyway, as the name is fairly common.

R=rsc
CC=golang-dev
https://golang.org/cl/5294071
2011-10-26 15:27:59 -07:00
Hector Chu
aed2c06dcb 5a, 5c, 6a, 6c, 8a, 8c: fix Windows file paths
Verified with objdump -W.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4974061
2011-09-07 15:49:56 -04:00
Lucio De Re
c8c6e1961d 5c, 6c, 6l: fix Plan 9 build warnings
src/cmd/5c/reg.c:
. Added USED() attribute.

src/cmd/6c/cgen.c:
. Revised code around "REGARG" to resemble use in "8c" and
  consequently remove a warning.

src/cmd/6l/asm.c:
. Added USED() attributes.
. Removed an unnecessary assignment.

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4836045
2011-08-16 14:22:08 -04:00
Lucio De Re
4c6280b0f1 6a, 6c, 6l: fix for Plan 9 build
6a/a.h:
. Dropped <u.h> and <libc.h>.
. Made definition of EOF conditional.

6a/a.y:
. Added <u.h> and <libc.h>.

6a/lex.c:
. Added <u.h> and <libc.h>.
. Dropped <ctype.h> (now in <u.h>).

6c/gc.h:
. Added varargck pragma for "lD".

6c/swt.c:
. Dropped unused "thestring" argument in Bprint() calls.

6l/Makefile:
. Dropped unneeded directory prefix.

6l/l.h:
. Dropped unneeded directory prefix.
. Added varargck pragma for "I" and "i".

6l/obj.c:
. Dropped unneeded assignment.
. Dropped unreachable goto statement.

6l/pass.c:
. Dropped assignments flagged as unused.

6l/prof.c:
. Replaced "#if 0" with "#ifdef NOTDEF".

6l/span.c:
. Dropped unused incrementation.
. Added USED() as required.
. Dropped unreachable "return" statement.

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/4747044
2011-07-15 11:58:39 -04:00
Russ Cox
1eb656784c 5c, 6c: fix build
R=ken2
CC=golang-dev
https://golang.org/cl/4668049
2011-07-01 11:13:38 -04:00
Dave Cheney
cbb2d8e20e cc: nit: silence comment warnings
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/4648043
2011-06-19 13:58:08 +10:00
Russ Cox
1d26908d3f build: use gcc -Werror
Better to fix the warnings that we find.

R=iant
CC=golang-dev
https://golang.org/cl/4406042
2011-04-13 16:18:09 -04:00
Russ Cox
3f61184e1b gc, ld: detect stale or incompatible object files
The object files begin with a header that is

        $GOARCH

on a line by itself.  This CL changes that header to

        go object $GOOS $GOARCH release.2011-01-01 4567+

where the final two fields are the most recent release
tag and the current hg version number.

All objects imported into a Go compilation or linked into an
executable must have the same header line, and that header
line must match the compiler and linker versions.

The effect of this will be that if you update and run all.bash
and then try to link in objects compiled with an earlier version
of the compiler (or invoke the wrong version of the compiler),
you will get an error showing the different headers instead
of perhaps silent incompatibility.

Normal usage with all.bash should be unaffected, because
all.bash deletes all the object files in $GOROOT/pkg/$GOOS_$GOARCH
and cleans all intermediate object files before starting.

This change is intended to diagnose stale objects arising when
users maintaining alternate installation directories forget to
rebuild some of their files after updating.

It should help make the adoption of $GOPATH (CL 3780043)
less error-prone.

R=ken2, r
CC=golang-dev
https://golang.org/cl/4023063
2011-02-03 13:51:43 -05:00
Russ Cox
dc9a3b2791 gc: align structs according to max alignment of fields
cc: same
runtime: test cc alignment (required moving #define of offsetof to runtime.h)
fix bug260

Fixes #482.
Fixes #609.

R=ken2, r
CC=golang-dev
https://golang.org/cl/3563042
2010-12-13 16:22:19 -05:00
Ian Lance Taylor
d853b594b4 6c: automatically #define _64BIT.
This makes it much easier to use a tool like Swig which needs
to run either 8c or 6c on generated code which #include's
"runtime.h".

R=ken2, rsc
CC=golang-dev
https://golang.org/cl/3205041
2010-11-18 10:26:41 -08:00
Russ Cox
d9c989fa25 various: avoid %ld etc
The Plan 9 tools assume that long is 32 bits.
We converted all instances of long to int32 when
importing the code but missed the print formats.
Because int32 is always int on the compilers we use,
it is never correct to use %lux, %ld, etc.  Convert to %ux, %d, etc.

(It matters because on 64-bit gcc, long is 64 bits,
so we were printing 32-bit quantities with 64-bit formats.)

R=ken2
CC=golang-dev
https://golang.org/cl/2491041
2010-10-13 16:20:22 -04:00
Russ Cox
2cda191aef 6c, 8c: show line numbers in -S output
R=ken2
CC=golang-dev
https://golang.org/cl/2107047
2010-09-10 11:53:51 -04:00
Russ Cox
aafe474ec9 build: $GOBIN defaults to $GOROOT/bin
R=r
CC=golang-dev
https://golang.org/cl/1982049
2010-08-24 20:00:33 -04:00
Russ Cox
e473f42b2d amd64: use segment memory for thread-local storage
Returns R14 and R15 to the available register pool.
Plays more nicely with ELF ABI C code.
In particular, our signal handlers will no longer crash
when a signal arrives during execution of a cgo C call.

Fixes #720.

R=ken2, r
CC=golang-dev
https://golang.org/cl/1847051
2010-08-04 17:50:22 -07:00
Rob Pike
9e481e2905 fix spelling of align
R=rsc
CC=golang-dev
https://golang.org/cl/778041
2010-03-26 09:56:57 -07:00
Ian Lance Taylor
9e0ae94e72 Add support for #pragma dynexport.
R=rsc
CC=golang-dev
https://golang.org/cl/661043
2010-03-23 06:46:30 -07:00
Ian Lance Taylor
f54d73b880 Rename dynld to dynimport throughout.
Cgo users will need to rerun cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/692041
2010-03-22 19:58:55 -07:00
Ken Thompson
60c2e5f453 issue 608
error compiling if(long long) in 6c compiler

R=rsc
CC=golang-dev
https://golang.org/cl/657042
2010-03-19 14:20:15 -07:00
Russ Cox
36c5c5bf40 cc: disallow ... argument unless NOSPLIT is set.
check that NOSPLIT functions don't use too much stack.
correct some missing NOSPLITs in the runtime library.

Fixes bug reported in
https://groups.google.com/group/golang-nuts/t/efff68b73941eccf

R=ken2
CC=golang-dev
https://golang.org/cl/236041
2010-03-04 15:34:25 -08:00
Ken Thompson
424f9ca6ab change print print buffer size
to go with the full path names

R=rsc
CC=golang-dev
https://golang.org/cl/195079
2010-01-27 15:37:46 -08:00
Charles L. Dorian
3ca1b1d27f Continuation of issue 221 fix. When 8g or 6g or 5g are called with a
UTF-8 string, Yconv() converts it into an octal sequence. If the
string converted to more than 30 bytes, the str buffer would
overflow. For example, 4 Greek runes became 32 bytes, 3 Hiragana
runes became 36 bytes, and 2 Gothic runes became 32 bytes. In
8l, 6l and 5l the function is Sconv(). For some reason, only 5l uses
the constant STRINGSZ (defined as 200) for the buffer size.

R=rsc
https://golang.org/cl/168045
2009-12-09 11:56:45 -08:00
Sergio Luis O. B. Correia
6fc820729e go: makes it build for the case $GOROOT has whitespaces
the bash scripts and makefiles for building go didn't take into account
the fact $GOROOT / $GOBIN could both be directories containing whitespaces,
and was not possible to build it in such a situation.

this commit adjusts the various makefiles/scripts to make it aware of that
possibility, and now it builds successfully when using a path with whitespaces
as well.

Fixes #115.

R=rsc, dsymonds1
https://golang.org/cl/157067
2009-11-23 17:32:51 -08:00
Russ Cox
18ccbc69f8 tweak documentation of commands
so that first sentence is better for cmd page.

live at http://r45:3456/cmd/

R=gri, r
http://go/go-review/1024034
2009-11-09 11:45:15 -08:00
Rob Pike
2bc63f2367 First steps at command documentation: C compilers and linkers.
Each command gets a doc.go file for godoc to analyze. Its main
element is a package comment.

R=rsc
CC=go-dev
http://go/go-review/1018029
2009-11-03 16:05:47 -08:00
Russ Cox
11d3805579 clean more
R=r
DELTA=40  (9 added, 3 deleted, 28 changed)
OCL=35277
CL=35305
2009-10-03 10:38:03 -07:00
Russ Cox
165a99038f ffi -> dynld.
move out of export data into its own section

R=r
DELTA=222  (71 added, 99 deleted, 52 changed)
OCL=33801
CL=33808
2009-08-24 17:27:55 -07:00
Russ Cox
8c253bcae5 first attempt at real FFI support.
in a .6 file, an export line

	//ffi T localfib remotefib remote.so

means the dynamic linker should initialize
localfib, always a pointer, to the address of
remotefib, either text (T) or data (D) after
loading remote.so.

the C compiler will generate an export section
when given the pragmas

	#pragma package fib
	#pragma ffi T localfib remotefib remote.so

needing #pragma package is a bit of a kludge
and hopefully could go away later.

this is just the 6 tool chain support.
other architectures will happen once 6 settles down.

code using this to do FFI is in a later CL.

R=r
DELTA=161  (141 added, 14 deleted, 6 changed)
OCL=33783
CL=33795
2009-08-24 16:15:21 -07:00
Rob Pike
7b366e9c43 fix build
R=rsc
DELTA=1  (0 added, 0 deleted, 1 changed)
OCL=33174
CL=33174
2009-08-13 09:35:42 -07:00
Russ Cox
f63b0d6b71 silence gcc warning
R=ken
OCL=33144
CL=33144
2009-08-12 18:14:07 -07:00