aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/util.go
AgeCommit message (Collapse)Author
2015-05-01cmd/internal/obj: remove Biobuf ungetDave Cheney
This change applies CL 9365 to the copy of Biobuf in cmd/internal/obj. In the process I discovered that some of the methods that should have been checking the unget buffer before reading were not and it was probably just dumb luck that we handn't hit these issues before; Bungetc is only used in one place in cmd/internal/gc and only an unlikely code path. Change-Id: Ifa0c5c08442e9fe951a5078c6e9ec77a8a4dc2ff Reviewed-on: https://go-review.googlesource.com/9529 Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net> Run-TryBot: Dave Cheney <dave@cheney.net>
2015-05-01cmd/internal/obj: clean up BiobufDave Cheney
This is a follow up to rev 443a32e707d2 which reduces some of the duplication between methods and functions that operate on obj.Biobuf. obj.Biobuf has Flush and Write methods as well as helpers which duplicate those methods, consolidate on the former and remove the latter. Also, address a final comment from CL 9525. Change-Id: I67deaf3a163bb489a9bb21bb39524785d7a2f6c5 Reviewed-on: https://go-review.googlesource.com/9527 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-22cmd/5g, etc, cmd/internal/gc, cmd/internal/obj, etc: coalesce bool2int ↵Michael Hudson-Doyle
implementations There were 10 implementations of the trivial bool2int function, 9 of which were the only thing in their file. Remove all of them in favor of one in cmd/internal/obj. Change-Id: I9c51d30716239df51186860b9842a5e9b27264d3 Reviewed-on: https://go-review.googlesource.com/9230 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20cmd/internal: C->Go printf cleanupBrad Fitzpatrick
Change-Id: I1cf94377c613fb51ae77f4fe1e3439268b1606a9 Reviewed-on: https://go-review.googlesource.com/9161 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-10cmd/internal/obj/x86, cmd/internal/ld, cmd/6l: 6g/asm -dynlink accesses ↵Michael Hudson-Doyle
global data via a GOT Change-Id: I49862e177045369d6c94d6a58afbdace4f13cc96 Reviewed-on: https://go-review.googlesource.com/8237 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-20cmd/internal/obj: replace Addr.U struct {...} with Val interface{}Russ Cox
An interface{} is more in the spirit of the original union. By my calculations, on 64-bit systems this reduces Addr from 120 to 80 bytes, and Prog from 592 to 424 bytes. Change-Id: I0d7b0981513c2a3c94c9ac76bb4f8816485b5a3c Reviewed-on: https://go-review.googlesource.com/7744 Reviewed-by: Rob Pike <r@golang.org>
2015-03-16cmd/internal/obj, cmd/internal/obj/arm64: add support for GOARCH=arm64Aram Hăvărneanu
ARM64 (ARMv8) has 32 general purpose, 64-bit integer registers (R0-R31), 32 64-bit scalar floating point registers (F0-F31), and 32 128-bit vector registers (unused, V0-V31). R31 is either the stack pointer (RSP), or the zero register (ZR), depending on the instruction. Note the distinction between the hardware stack pointer, RSP, and the virtual stack pointer SP. The (hardware) stack pointer must be 16-byte aligned at all times; the RSP register itself must be aligned, offset(RSP) only has to have natural alignment. Instructions are fixed-width, and are 32-bit wide. ARM64 supports ARMv7 too (32-bit ARM), but not in the same process. In general, there is not much in common between 32-bit ARM and ARM64, it's a new architecture. All implementations have floating point instructions. This change adds a Prog.To3 field analogous to Prog.To. It is used by exclusive load/store instructions such as STLXR which read from one register, and write to both a register and a memory address. STLXRW R1, (R0), R3 This will store the word contained in R1 to the memory address pointed by R0. R3 will be updated with the status result of the store. It is used to implement atomic operations. No other changes are made to the portable Prog and Addr structures. Change-Id: Ie839029aa5265bbad35769d9689eca11e1c48c47 Reviewed-on: https://go-review.googlesource.com/7046 Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-05cmd/internal/obj: delete all Pconv, replace with Prog.StringRob Pike
Remove the per-achitecture formatter for Prog and replace it with a global String method. Clean up and regularize the output. Update tests affected by the format; some tests are made correct now when they were broken before (and known to be). Also, related: Change the encoding of the (R1+R2) syntax on ppc64 to be equivalent to (R1)(R2*1), which means it needs no special handling. Delete the now unused STRINGSZ constant. Change-Id: I7f6654d11f80065f3914a3f19353f2f12edfe310 Reviewed-on: https://go-review.googlesource.com/6931 Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-03cmd/internal/obj: switch to one global AconvRob Pike
Aconv is the pretty-printer for instruction opcodes like AMOVQ. There was one for each architecture. Make the space of A names have a different region for each architecture, much as we did for the registers, so a single global Aconv function can do the work. Each architecture registers its region as a slice of names at a given offset. The global names like CALL and JMP are now defined only once. The A values are used for indexing tables, so make it easy to do the indexing by making the offset maskable. Remove a bunch of now-duplicated architecture-specific code. Change-Id: Ib15647b7145a1c089e21e36543691a19e146b60e Reviewed-on: https://go-review.googlesource.com/6620 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-01cmd/dist: record default GO_EXTLINK_ENABLED in GoRuss Cox
Today it's only recorded for C, but the Go version of the linker will need it. Change-Id: I0de56d98e8f3f1b7feb830458c0934af367fd29a Reviewed-on: https://go-review.googlesource.com/6333 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
2015-02-28cmd/internal/gc, cmd/internal/obj: remove pointless fmt.Sprintf callsJosh Bleecher Snyder
This is a follow-up to CL 6265. No behavior changes. The diff was generated with eg, using template: package p import "fmt" func before(a string) string { return fmt.Sprintf(a) } func after(a string) string { return a } Change-Id: I7b3bebf31be5cd1ae2233da06cb4502a3d73f092 Reviewed-on: https://go-review.googlesource.com/6269 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-28cmd/internal/obj: clean up handling of register list operand on ARMRob Pike
ARM operands for MOVM have lists of registers: [R1,R2,R5-R8]. Handle them cleanly. It was TYPE_CONST with special handling, which meant operand printing didn't work right and the special handling was ugly. Add a new TYPE_REGLIST for this case and it all gets cleaner. Change-Id: I4a64f70fb9765e63cb636619a7a8553611bfe970 Reviewed-on: https://go-review.googlesource.com/6300 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-27cmd/internal/obj: make Rconv a global functionRob Pike
Clean up the obj API by making Rconv (register pretty printer) a top-level function. This means that Dconv (operand pretty printer) doesn't need an Rconv argument. To do this, we make the register numbers, which are arbitrary inside an operand (obj.Addr), disjoint sets for each architecture. Each architecture registers (ha) a piece of the space and then the global Rconv knows which architecture-specific printer to use. Clean up all the code that uses Dconv. Now register numbers are large, so a couple of fields in Addr need to go from int8 to int16 because they sometimes hold register numbers. Clean up their uses, which meant regenerating the yacc grammars for the assemblers. There are changes in this CL triggered by earlier changes to yacc, which had not been run in this directory. There is still cleanup to do in Addr, but we're getting closer to that being easy to do. Change-Id: I9290ebee013b62f7d24e886743ea5a6b232990ab Reviewed-on: https://go-review.googlesource.com/6220 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-26cmd/internal/obj: implement Dconv for TYPE_INDIRRob Pike
It was just missing, and apparently always was. Change-Id: I84c057bb0ec72940201075f3e6078262fe4bce05 Reviewed-on: https://go-review.googlesource.com/6120 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-25cmd/internal/obj: make Dconv a portable top-level functionRob Pike
Each architecture had its own Dconv (operand printer) but the syntax is close to uniform and the code overlap was considerable. Consolidate these into a single top-level function. A similar but smaller unification is done for Mconv ("Name" formatter) as well. The signature is changed. The flag was unused so drop it. Add a function argument, Rconv, that must be supplied by the caller. TODO: A future change will unify Rconv as well and this argument will go away. Some formats changed, because of the automatic consistency created by unification. For instance, 0(R1) always prints as (R1) now, and foo+0(SB) is just foo(SB). Before, some made these simplifications and some didn't; now they all do. Update the asm tests that depend on the format. Change-Id: I6e3310bc19814c0c784ff0b960a154521acd9532 Reviewed-on: https://go-review.googlesource.com/5920 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17[dev.cc] cmd/internal/gc, cmd/new6g etc: convert from cmd/gc, cmd/6g etcRuss Cox
First draft of converted Go compiler, using rsc.io/c2go rev 83d795a. Change-Id: I29f4c7010de07d2ff1947bbca9865879d83c32c3 Reviewed-on: https://go-review.googlesource.com/4851 Reviewed-by: Rob Pike <r@golang.org>
2015-02-05[dev.cc] cmd/internal/obj: reconvert from liblinkRuss Cox
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256. - Brings in new, more regular Prog, Addr definitions - Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion. - Update objwriter for change in TEXT size encoding. - Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand). - Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm. They need to be updated for the changes. - Reenable verifyAsm in cmd/go. - Reenable GOOBJ=2 mode by default in liblink. All architectures build successfully again. Change-Id: I2c845c5d365aa484b570476898171bee657b626d Reviewed-on: https://go-review.googlesource.com/3963 Reviewed-by: Rob Pike <r@golang.org>
2015-01-22[dev.cc] cmd/internal/obj, cmd/new9a: use ctxt.NewProgRuss Cox
cmd/internal/obj reconverted using rsc.io/c2go rev 40275b8. All Prog*s need Ctxt field set so that the printer can tell which architecture the Prog belongs to. Use ctxt.NewProg consistently for this. Change-Id: Ic981b3d68f24931ffae74a772e83a3dc2fdf518a Reviewed-on: https://go-review.googlesource.com/3152 Reviewed-by: Rob Pike <r@golang.org>
2015-01-21[dev.cc] cmd/internal/obj: reconvert from liblinkRuss Cox
Using rsc.io/c2go repo revision 60c9302. - Export a few symbols needed by assemblers. - Implement Getgoroot etc directly, and add Getgoversion. - Removes dependency on Go 1.4 go/build. - Change magic history name <no name> to <pop> The <pop> change requires adjustment to the liblink serializer. Change-Id: If5fb52ac9e91d50805263070b3fc5cc05d8b7632 Reviewed-on: https://go-review.googlesource.com/3141 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2015-01-21[dev.cc] cmd/internal/obj: convert liblink C to GoRuss Cox
This CL adds the real cmd/internal/obj packages. Collectively they correspond to the liblink library. The conversion was done using rsc.io/c2go's run script at rsc.io/c2go repo version 706fac7. This is not the final conversion, just the first working draft. There will be more updates, but this works well enough to use with go tool objwriter and pass all.bash. Change-Id: I9359e835425f995a392bb2fcdbebf29511477bed Reviewed-on: https://go-review.googlesource.com/3046 Reviewed-by: Ian Lance Taylor <iant@golang.org>