aboutsummaryrefslogtreecommitdiff
path: root/doc/asm.html
AgeCommit message (Collapse)Author
2021-08-10doc: use "high address/low address" instead of "top/bottom"fanzha02
The current document uses the "top" and "bottom" when talking about the address within a frame, which may easily lead to misunderstandings. This patch directly uses "high address" and "low address" to make the expression clearer. Change-Id: I7469330bbdc158672d7f0314fe6680ebdd9ab79a Reviewed-on: https://go-review.googlesource.com/c/go/+/339369 Trust: fannie zhang <Fannie.Zhang@arm.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-07-07doc: remove stale comment about arm64 portMichael Anthony Knyszek
Fixes #47079. Change-Id: I8a671e3fdc13083e44e8d89064a5e7621e53bc4c Reviewed-on: https://go-review.googlesource.com/c/go/+/333075 Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-25doc/asm: add a section on go_asm.h, clean up go_tls.h sectionAustin Clements
Currently the only mention of go_asm.h is buried in a confusing section about the runtime-specific go_tls.h header. We actually want people to use go_asm.h, so this CL adds a section with a proper discussion of this header. As part of this, we remove the discussion of go_asm.h from the go_tls.h section and clean up what remains. I stumbled on this when working on the internal ABI specification. I wanted to refer to stable documentation on how to access struct fields from assembly and found there was none. Change-Id: I0d53741e7685e65794611939e76285f7c82e1d65 Reviewed-on: https://go-review.googlesource.com/c/go/+/286052 Trust: Austin Clements <austin@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2020-09-01doc/asm: add BP is callee-save paragraphEgon Elbre
Change-Id: Id38e639c66a42acf0b1c4488cdfd0b7b6cf71c78 Reviewed-on: https://go-review.googlesource.com/c/go/+/250397 Reviewed-by: Keith Randall <khr@golang.org>
2020-05-01doc, cmd/internal/obj/arm64: update the directives in the docfanzha02
Adding the usage of PCALIGN directive for arm64, and updating some details on using some directives defined in the textflag.h file. Change-Id: I43d363e3337939bab69b856831caf06803a292d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/227801 Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-16doc: update ppc64 section for asm.htmlLynn Boger
Update the section in asm.html related to PPC64. Remove the line that says it is in an experimental state, add a link to the new doc.go file that has all the detail for the Go assembler for PPC64. Change-Id: I45d9891669e01d94e2721be576d572e02cd9d2db Reviewed-on: https://go-review.googlesource.com/c/go/+/183840 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-11doc/asm: document go_asm.h only works in the runtime packagePure White
Fixes #33054 Change-Id: I687d45e092d721a6c22888cc7ddbe420c16a5af9 GitHub-Last-Rev: a7208c89a0d613a53ab057e0b4418ae4719cfcbd GitHub-Pull-Request: golang/go#33069 Reviewed-on: https://go-review.googlesource.com/c/go/+/185917 Reviewed-by: Rob Pike <r@golang.org>
2019-05-08doc: update /doc/asm compiler output exampleRuss Cox
The compiler output shown in the doc is now quite old (most of the changes happened in Go 1.5). Update it to be more like what users will actually see. Also explain how to get literal machine code again. Prompted by #30968. Change-Id: I0ce139c3fe299ccc43e85b6aca81c6e0aac1a2df Reviewed-on: https://go-review.googlesource.com/c/go/+/175757 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2018-11-06cmd/asm: rename R18 to R18_PLATFORM on ARM64Cherry Zhang
In ARM64 ABI, R18 is the "platform register", the use of which is OS specific. The OS could choose to reserve this register. In practice, it seems fine to use R18 on Linux but not on darwin (iOS). Rename R18 to R18_PLATFORM to prevent accidental use. There is no R18 usage within the standard library (besides tests, which are updated). Fixes #26110 Change-Id: Icef7b9549e2049db1df307a0180a3c90a12d7a84 Reviewed-on: https://go-review.googlesource.com/c/147218 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-27cmd/compile: add softfloat support to mips64{,le}Milan Knezevic
mips64 softfloat support is based on mips implementation and introduces new enviroment variable GOMIPS64. GOMIPS64 is a GOARCH=mips64{,le} specific option, for a choice between hard-float and soft-float. Valid values are 'hardfloat' (default) and 'softfloat'. It is passed to the assembler as 'GOMIPS64_{hardfloat,softfloat}'. Change-Id: I7f73078627f7cb37c588a38fb5c997fe09c56134 Reviewed-on: https://go-review.googlesource.com/108475 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-20cmd/internal/obj/arm64: summarize the Go assembly syntax and the GNU syntax ↵fanzha02
mapping rules The patch rewrites the content of doc.go file. The file describes some general rules of the mapping between Go assembly syntax and GNU syntax. And it gives some Go assembly examples and corresponding GNU assembly examples. The patch changes the doc.go to use standard doc comment format so that the link https://golang.org/cmd/internal/obj/arm64/ can display it. Assembly document framework is mainly contributed by Eric Fang <Eric.Fang@arm.com> Documentation work is contributed by Eric Fang and Fannie Zhang <Fannie.Zhang@arm.com> Change-Id: I8b3f6d6c6b91afdc2c44602e8f796beea905085e Reviewed-on: https://go-review.googlesource.com/102055 Reviewed-by: Rob Pike <r@golang.org>
2018-01-09doc: s/tool chain/toolchain/Russ Cox
We were not being consistent. Standardize on toolchain. Change-Id: Id0e756b5214ce4a1341f733634ed95263f03a61c Reviewed-on: https://go-review.googlesource.com/87017 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-30cmd/go, cmd/dist: introduce GOMIPS environment variableVladimir Stefanovic
GOMIPS is a GOARCH=mips{,le} specific option, for a choice between hard-float and soft-float. Valid values are 'hardfloat' (default) and 'softfloat'. It is passed to the assembler as 'GOMIPS_{hardfloat,softfloat}'. Note: GOMIPS will later also be used for a choice of MIPS instruction set (mips32/mips32r2). Updates #18162 Change-Id: I35417db8625695f09d6ccc3042431dd2eaa756a6 Reviewed-on: https://go-review.googlesource.com/37954 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-12-20doc: add mips, mips64 information to asm.htmlVladimir Stefanovic
Fixes #18105 Change-Id: Id56e8782ff618761ec44b6dc20891c8b48fea8df Reviewed-on: https://go-review.googlesource.com/34632 Reviewed-by: Rob Pike <r@golang.org>
2016-07-26doc: add s390x information to asm.htmlMichael Munday
Fixes #16362 Change-Id: I676718a1149ed2f3ff80cb031e25de7043805399 Reviewed-on: https://go-review.googlesource.com/25157 Reviewed-by: Rob Pike <r@golang.org>
2016-02-16doc: fix remaining TODOs in Go 1.6 release notesRuss Cox
Fixes #14300. Change-Id: Idb6a300fe0e06fb8966cf06b55f9b252752a69a6 Reviewed-on: https://go-review.googlesource.com/19459 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-04doc: rewrite references to plan9.bell-labs.com to 9p.ioAndrew Gerrand
The plan9.bell-labs.com site has fallen into disrepair. We'll instead use the site maintained by contributor David du Colombier. Fixes #14233 Change-Id: I0c702e5d3b091cccd42b288ea32f34d507a4733d Reviewed-on: https://go-review.googlesource.com/19240 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com>
2016-01-14cmd/compile: recognize Syscall-like functions for liveness analysisRuss Cox
Consider this code: func f(*int) func g() { p := new(int) f(p) } where f is an assembly function. In general liveness analysis assumes that during the call to f, p is dead in this frame. If f has retained p, p will be found alive in f's frame and keep the new(int) from being garbage collected. This is all correct and works. We use the Go func declaration for f to give the assembly function liveness information (the arguments are assumed live for the entire call). Now consider this code: func h1() { p := new(int) syscall.Syscall(1, 2, 3, uintptr(unsafe.Pointer(p))) } Here syscall.Syscall is taking the place of f, but because its arguments are uintptr, the liveness analysis and the garbage collector ignore them. Since p is no longer live in h once the call starts, if the garbage collector scans the stack while the system call is blocked, it will find no reference to the new(int) and reclaim it. If the kernel is going to write to *p once the call finishes, reclaiming the memory is a mistake. We can't change the arguments or the liveness information for syscall.Syscall itself, both for compatibility and because sometimes the arguments really are integers, and the garbage collector will get quite upset if it finds an integer where it expects a pointer. The problem is that these arguments are fundamentally untyped. The solution we have taken in the syscall package's wrappers in past releases is to insert a call to a dummy function named "use", to make it look like the argument is live during the call to syscall.Syscall: func h2() { p := new(int) syscall.Syscall(1, 2, 3, uintptr(unsafe.Pointer(p))) use(unsafe.Pointer(p)) } Keeping p alive during the call means that if the garbage collector scans the stack during the system call now, it will find the reference to p. Unfortunately, this approach is not available to users outside syscall, because 'use' is unexported, and people also have to realize they need to use it and do so. There is much existing code using syscall.Syscall without a 'use'-like function. That code will fail very occasionally in mysterious ways (see #13372). This CL fixes all that existing code by making the compiler do the right thing automatically, without any code modifications. That is, it takes h1 above, which is incorrect code today, and makes it correct code. Specifically, if the compiler sees a foreign func definition (one without a body) that has uintptr arguments, it marks those arguments as "unsafe uintptrs". If it later sees the function being called with uintptr(unsafe.Pointer(x)) as an argument, it arranges to mark x as having escaped, and it makes sure to hold x in a live temporary variable until the call returns, so that the garbage collector cannot reclaim whatever heap memory x points to. For now I am leaving the explicit calls to use in package syscall, but they can be removed early in a future cycle (likely Go 1.7). The rule has no effect on escape analysis, only on liveness analysis. Fixes #13372. Change-Id: I2addb83f70d08db08c64d394f9d06ff0a063c500 Reviewed-on: https://go-review.googlesource.com/18584 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06doc: fix incorrect example in asm.htmlIan Lance Taylor
Fixes #13845. Change-Id: Ie83179b2d20c47a0296645d9e2fdc43271be495a Reviewed-on: https://go-review.googlesource.com/18307 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-19doc/go1.5.html: refer to ppc64 as 64-bit PowerPC, not Power 64Russ Cox
Saying "Power 64" was wrong for reasons I don't remember. (Those reasons are why we stopped using GOARCH=power64.) Change-Id: Ifaac78d5733bfc780df01b1a66da766af0b17726 Reviewed-on: https://go-review.googlesource.com/13675 Reviewed-by: Rob Pike <r@golang.org>
2015-07-23doc: mention the ppc64(le) ports in release notesRob Pike
Also make the spelling consistent in asm.html Change-Id: Ifa751eee288fe0634cd317eb827f3e408b199620 Reviewed-on: https://go-review.googlesource.com/12501 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-15doc: add a few more details about arm and ppc64 to asm.htmlRob Pike
Update #10096 Arm64 and Ppc64 are still pretty sketchy. Change-Id: Iaf821b0f17bad8c71d338d45de75d4a345cac2dd Reviewed-on: https://go-review.googlesource.com/12160 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-13doc: update the architecture-specific information in asm.htmlRob Pike
Still to do: ARM64 and PPC64. These architectures are woefully underdocumented. Change-Id: Iedcf767a7e0e1c931812351940bc08f0c3821212 Reviewed-on: https://go-review.googlesource.com/12110 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-09doc: document the machine-independent changes to the assemblerRob Pike
The architecture-specific details will be updated and expanded in a subsequent CL (or series thereof). Update #10096 Change-Id: I59c6be1fcc123fe8626ce2130e6ffe71152c87af Reviewed-on: https://go-review.googlesource.com/11954 Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26Fix several out of date references to 4g/5g/6g/8g/9g.Aaron Jacobs
Change-Id: Ifb8e4e13c7778a7c0113190051415e096f5db94f Reviewed-on: https://go-review.googlesource.com/11390 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-15doc/asm: document that assembly function must use short nameShenghou Ma
e.g. ·Name instead of package·Name for automatic stack map to be applied from its Go prototype. The underlying reason is that liblink look up name with suffix ".args_stackmap" for the stackmap coming from its Go prototype, but all the Go functions are named "".Name as this stage. Thus an assembly function named package·Name will never find its stackmap, which is named "".package.Name.args_stackmap. Perhaps cmd/vet should give a warning for this. Change-Id: I10d154a73ec969d574d20af877f747424350fbd1 Reviewed-on: https://go-review.googlesource.com/2588 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-10-28doc/asm: explain coordination with garbage collectorRuss Cox
Also a few other minor changes. Fixes #8712. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/164150043
2014-08-12all: copy cmd/ld/textflag.h into pkg/GOOS_GOARCHRob Pike
The file is used by assembly code to define symbols like NOSPLIT. Having it hidden inside the cmd directory makes it hard to access outside the standard repository. Solution: As with a couple of other files used by cgo, copy the file into the pkg directory and add a -I argument to the assembler to access it. Thus one can write just #include "textflag.h" in .s files. The names in runtime are not updated because in the boot sequence the file has not been copied yet when runtime is built. All other .s files in the repository are updated. Changes to doc/asm.html, src/cmd/dist/build.c, and src/cmd/go/build.go are hand-made. The rest are just the renaming done by a global substitution. (Yay sam). LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/128050043
2014-06-26all: remove 'extern register M *m' from runtimeRuss Cox
The runtime has historically held two dedicated values g (current goroutine) and m (current thread) in 'extern register' slots (TLS on x86, real registers backed by TLS on ARM). This CL removes the extern register m; code now uses g->m. On ARM, this frees up the register that formerly held m (R9). This is important for NaCl, because NaCl ARM code cannot use R9 at all. The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected: BenchmarkBinaryTree17 5491374955 5471024381 -0.37% BenchmarkFannkuch11 4357101311 4275174828 -1.88% BenchmarkGobDecode 11029957 11364184 +3.03% BenchmarkGobEncode 6852205 6784822 -0.98% BenchmarkGzip 650795967 650152275 -0.10% BenchmarkGunzip 140962363 141041670 +0.06% BenchmarkHTTPClientServer 71581 73081 +2.10% BenchmarkJSONEncode 31928079 31913356 -0.05% BenchmarkJSONDecode 117470065 113689916 -3.22% BenchmarkMandelbrot200 6008923 5998712 -0.17% BenchmarkGoParse 6310917 6327487 +0.26% BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17% BenchmarkRegexpMatchHard_1K 168977 169244 +0.16% BenchmarkRevcomp 935294971 914060918 -2.27% BenchmarkTemplate 145917123 148186096 +1.55% Minux previous reported larger variations, but these were caused by run-to-run noise, not repeatable slowdowns. Actual code changes by Minux. I only did the docs and the benchmarking. LGTM=dvyukov, iant, minux R=minux, josharian, iant, dave, bradfitz, dvyukov CC=golang-codereviews https://golang.org/cl/109050043
2014-04-27doc: fix an articleBrad Fitzpatrick
LGTM=r R=r CC=golang-codereviews https://golang.org/cl/91770050
2014-04-15doc/asm.html: remove mention of 6l -aRob Pike
Also make it clear this is not a complete description of all features. Fixes #7790. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/88300044
2013-11-13doc/asm: more about SP, ARM R11Russ Cox
Also rename URL to /doc/asm. R=golang-dev, minux.ma, r CC=golang-dev https://golang.org/cl/26170043
2013-11-12doc/asm.html: new document, a brief guide to the assemblerRob Pike
Fixes #6060 R=golang-dev, iant, bradfitz, josharian, minux.ma, aram, rsc CC=golang-dev https://golang.org/cl/20930043