doc: forgot to regenerate on last commit

This commit is contained in:
Michael McLoughlin
2019-01-06 20:16:26 -08:00
parent 304c7425d2
commit 4f73a6ea72
10 changed files with 36 additions and 30 deletions

View File

@@ -41,7 +41,7 @@ import (
) )
func main() { func main() {
TEXT("Add", "func(x, y uint64) uint64") TEXT("Add", NOSPLIT, "func(x, y uint64) uint64")
Doc("Add adds x and y.") Doc("Add adds x and y.")
x := Load(Param("x"), GP64()) x := Load(Param("x"), GP64())
y := Load(Param("y"), GP64()) y := Load(Param("y"), GP64())
@@ -65,8 +65,10 @@ After running `go generate` the [`add.s`](examples/add/add.s) file will contain
```s ```s
// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT. // Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"
// func Add(x uint64, y uint64) uint64 // func Add(x uint64, y uint64) uint64
TEXT ·Add(SB), $0-24 TEXT ·Add(SB), NOSPLIT, $0-24
MOVQ x(FP), AX MOVQ x(FP), AX
MOVQ y+8(FP), CX MOVQ y+8(FP), CX
ADDQ AX, CX ADDQ AX, CX
@@ -99,7 +101,7 @@ Sum a slice of `uint64`s:
[embedmd]:# (examples/sum/asm.go /func main/ /^}/) [embedmd]:# (examples/sum/asm.go /func main/ /^}/)
```go ```go
func main() { func main() {
TEXT("Sum", "func(xs []uint64) uint64") TEXT("Sum", NOSPLIT, "func(xs []uint64) uint64")
Doc("Sum returns the sum of the elements in xs.") Doc("Sum returns the sum of the elements in xs.")
ptr := Load(Param("xs").Base(), GP64()) ptr := Load(Param("xs").Base(), GP64())
n := Load(Param("xs").Len(), GP64()) n := Load(Param("xs").Len(), GP64())
@@ -135,8 +137,10 @@ The result from this code generator is:
```s ```s
// Code generated by command: go run asm.go -out sum.s -stubs stub.go. DO NOT EDIT. // Code generated by command: go run asm.go -out sum.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"
// func Sum(xs []uint64) uint64 // func Sum(xs []uint64) uint64
TEXT ·Sum(SB), $0-32 TEXT ·Sum(SB), NOSPLIT, $0-32
MOVQ xs_base(FP), AX MOVQ xs_base(FP), AX
MOVQ xs_len+8(FP), CX MOVQ xs_len+8(FP), CX
XORQ DX, DX XORQ DX, DX
@@ -160,7 +164,7 @@ Full example at [`examples/sum`](examples/sum).
[embedmd]:# (examples/args/asm.go go /.*TEXT.*StringLen/ /Load.*/) [embedmd]:# (examples/args/asm.go go /.*TEXT.*StringLen/ /Load.*/)
```go ```go
TEXT("StringLen", "func(s string) int") TEXT("StringLen", NOSPLIT, "func(s string) int")
strlen := Load(Param("s").Len(), GP64()) strlen := Load(Param("s").Len(), GP64())
``` ```
@@ -168,7 +172,7 @@ Index an array:
[embedmd]:# (examples/args/asm.go go /.*TEXT.*ArrayThree/ /Load.*/) [embedmd]:# (examples/args/asm.go go /.*TEXT.*ArrayThree/ /Load.*/)
```go ```go
TEXT("ArrayThree", "func(a [7]uint64) uint64") TEXT("ArrayThree", NOSPLIT, "func(a [7]uint64) uint64")
a3 := Load(Param("a").Index(3), GP64()) a3 := Load(Param("a").Index(3), GP64())
``` ```
@@ -176,7 +180,7 @@ Access a struct field (provided you have loaded your package with the `Package`
[embedmd]:# (examples/args/asm.go go /.*TEXT.*FieldFloat64/ /Load.*/) [embedmd]:# (examples/args/asm.go go /.*TEXT.*FieldFloat64/ /Load.*/)
```go ```go
TEXT("FieldFloat64", "func(s Struct) float64") TEXT("FieldFloat64", NOSPLIT, "func(s Struct) float64")
f64 := Load(Param("s").Field("Float64"), XMM()) f64 := Load(Param("s").Field("Float64"), XMM())
``` ```
@@ -184,7 +188,7 @@ Component accesses can be arbitrarily nested:
[embedmd]:# (examples/args/asm.go go /.*TEXT.*FieldArrayTwoBTwo/ /Load.*/) [embedmd]:# (examples/args/asm.go go /.*TEXT.*FieldArrayTwoBTwo/ /Load.*/)
```go ```go
TEXT("FieldArrayTwoBTwo", "func(s Struct) byte") TEXT("FieldArrayTwoBTwo", NOSPLIT, "func(s Struct) byte")
b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8()) b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8())
``` ```
@@ -197,7 +201,7 @@ Very similar techniques apply to writing return values. See [`examples/args`](ex
[embedmd]:# (examples/sha1/asm.go /func main/ /^}/) [embedmd]:# (examples/sha1/asm.go /func main/ /^}/)
```go ```go
func main() { func main() {
TEXT("block", "func(h *[5]uint32, m []byte)") TEXT("block", 0, "func(h *[5]uint32, m []byte)")
Doc("block SHA-1 hashes the 64-byte message m into the running state h.") Doc("block SHA-1 hashes the 64-byte message m into the running state h.")
h := Mem{Base: Load(Param("h"), GP64())} h := Mem{Base: Load(Param("h"), GP64())}
m := Mem{Base: Load(Param("m").Base(), GP64())} m := Mem{Base: Load(Param("m").Base(), GP64())}

View File

@@ -15,7 +15,7 @@ import (
) )
func main() { func main() {
TEXT("Add", "func(x, y uint64) uint64") TEXT("Add", NOSPLIT, "func(x, y uint64) uint64")
Doc("Add adds x and y.") Doc("Add adds x and y.")
x := Load(Param("x"), GP64()) x := Load(Param("x"), GP64())
y := Load(Param("y"), GP64()) y := Load(Param("y"), GP64())
@@ -39,8 +39,10 @@ This produces [`add.s`](add.s) as follows:
```s ```s
// Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT. // Code generated by command: go run asm.go -out add.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"
// func Add(x uint64, y uint64) uint64 // func Add(x uint64, y uint64) uint64
TEXT ·Add(SB), $0-24 TEXT ·Add(SB), NOSPLIT, $0-24
MOVQ x(FP), AX MOVQ x(FP), AX
MOVQ y+8(FP), CX MOVQ y+8(FP), CX
ADDQ AX, CX ADDQ AX, CX

View File

@@ -8,7 +8,7 @@ Use `Param()` to reference arguments by name. The `Load()` function can be used
[embedmd]:# (asm.go go /.*TEXT.*Second/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*Second/ /RET.*/)
```go ```go
TEXT("Second", "func(x, y int32) int32") TEXT("Second", NOSPLIT, "func(x, y int32) int32")
y := Load(Param("y"), GP32()) y := Load(Param("y"), GP32())
Store(y, ReturnIndex(0)) Store(y, ReturnIndex(0))
RET() RET()
@@ -19,7 +19,7 @@ This `avo` code will generate the following assembly. Note that parameter refere
[embedmd]:# (args.s s /.*func Second/ /RET/) [embedmd]:# (args.s s /.*func Second/ /RET/)
```s ```s
// func Second(x int32, y int32) int32 // func Second(x int32, y int32) int32
TEXT ·Second(SB), $0-12 TEXT ·Second(SB), NOSPLIT, $0-12
MOVL y+4(FP), AX MOVL y+4(FP), AX
MOVL AX, ret+8(FP) MOVL AX, ret+8(FP)
RET RET
@@ -33,7 +33,7 @@ Strings and slices actually consist of multiple components under the hood: see [
[embedmd]:# (asm.go go /.*TEXT.*StringLen/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*StringLen/ /RET.*/)
```go ```go
TEXT("StringLen", "func(s string) int") TEXT("StringLen", NOSPLIT, "func(s string) int")
strlen := Load(Param("s").Len(), GP64()) strlen := Load(Param("s").Len(), GP64())
Store(strlen, ReturnIndex(0)) Store(strlen, ReturnIndex(0))
RET() RET()
@@ -47,7 +47,7 @@ Arrays can be indexed with the `Index()` method. For example, the following retu
[embedmd]:# (asm.go go /.*TEXT.*ArrayThree/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*ArrayThree/ /RET.*/)
```go ```go
TEXT("ArrayThree", "func(a [7]uint64) uint64") TEXT("ArrayThree", NOSPLIT, "func(a [7]uint64) uint64")
a3 := Load(Param("a").Index(3), GP64()) a3 := Load(Param("a").Index(3), GP64())
Store(a3, ReturnIndex(0)) Store(a3, ReturnIndex(0))
RET() RET()
@@ -86,7 +86,7 @@ The following function will return the `Float64` field from this struct.
[embedmd]:# (asm.go go /.*TEXT.*FieldFloat64/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*FieldFloat64/ /RET.*/)
```go ```go
TEXT("FieldFloat64", "func(s Struct) float64") TEXT("FieldFloat64", NOSPLIT, "func(s Struct) float64")
f64 := Load(Param("s").Field("Float64"), XMM()) f64 := Load(Param("s").Field("Float64"), XMM())
Store(f64, ReturnIndex(0)) Store(f64, ReturnIndex(0))
RET() RET()
@@ -98,7 +98,7 @@ Complex types `complex{64,128}` are actually just pairs of `float{32,64}` values
[embedmd]:# (asm.go go /.*TEXT.*FieldComplex64Imag/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*FieldComplex64Imag/ /RET.*/)
```go ```go
TEXT("FieldComplex64Imag", "func(s Struct) float32") TEXT("FieldComplex64Imag", NOSPLIT, "func(s Struct) float32")
c64i := Load(Param("s").Field("Complex64").Imag(), XMM()) c64i := Load(Param("s").Field("Complex64").Imag(), XMM())
Store(c64i, ReturnIndex(0)) Store(c64i, ReturnIndex(0))
RET() RET()
@@ -110,7 +110,7 @@ The above methods may be composed to reference arbitrarily nested data structure
[embedmd]:# (asm.go go /.*TEXT.*FieldArrayTwoBTwo/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*FieldArrayTwoBTwo/ /RET.*/)
```go ```go
TEXT("FieldArrayTwoBTwo", "func(s Struct) byte") TEXT("FieldArrayTwoBTwo", NOSPLIT, "func(s Struct) byte")
b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8()) b2 := Load(Param("s").Field("Array").Index(2).Field("B").Index(2), GP8())
Store(b2, ReturnIndex(0)) Store(b2, ReturnIndex(0))
RET() RET()

View File

@@ -6,7 +6,7 @@ The `Real()` and `Imag()` parameter methods may be used to load the sub-componen
[embedmd]:# (asm.go go /.*TEXT.*Norm/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*Norm/ /RET.*/)
```go ```go
TEXT("Norm", "func(z complex128) float64") TEXT("Norm", NOSPLIT, "func(z complex128) float64")
Doc("Norm returns the complex norm of z.") Doc("Norm returns the complex norm of z.")
r = Load(Param("z").Real(), XMM()) r = Load(Param("z").Real(), XMM())
i = Load(Param("z").Imag(), XMM()) i = Load(Param("z").Imag(), XMM())
@@ -24,7 +24,7 @@ Generated assembly:
[embedmd]:# (complex.s s /.*func Norm/ /RET/) [embedmd]:# (complex.s s /.*func Norm/ /RET/)
```s ```s
// func Norm(z complex128) float64 // func Norm(z complex128) float64
TEXT ·Norm(SB), $0-24 TEXT ·Norm(SB), NOSPLIT, $0-24
MOVSD z_real(FP), X0 MOVSD z_real(FP), X0
MOVSD z_imag+8(FP), X1 MOVSD z_imag+8(FP), X1
MULSD X0, X0 MULSD X0, X0

View File

@@ -21,7 +21,7 @@ The `GLOBL` function returns a reference which may be used in assembly code. The
[embedmd]:# (asm.go go /.*TEXT.*DataAt/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*DataAt/ /RET.*/)
```go ```go
TEXT("DataAt", "func(i int) byte") TEXT("DataAt", NOSPLIT, "func(i int) byte")
Doc("DataAt returns byte i in the 'bytes' global data section.") Doc("DataAt returns byte i in the 'bytes' global data section.")
i := Load(Param("i"), GP64()) i := Load(Param("i"), GP64())
ptr := Mem{Base: GP64()} ptr := Mem{Base: GP64()}

View File

@@ -10,7 +10,7 @@ const (
) )
func main() { func main() {
TEXT("Hash64", "func(data []byte) uint64") TEXT("Hash64", NOSPLIT, "func(data []byte) uint64")
Doc("Hash64 computes the FNV-1a hash of data.") Doc("Hash64 computes the FNV-1a hash of data.")
ptr := Load(Param("data").Base(), GP64()) ptr := Load(Param("data").Base(), GP64())
n := Load(Param("data").Len(), GP64()) n := Load(Param("data").Len(), GP64())

View File

@@ -7,7 +7,7 @@ Refer to ["Geohash in Golang Assembly"](https://mmcloughlin.com/posts/geohash-as
[embedmd]:# (asm.go /func main/ $) [embedmd]:# (asm.go /func main/ $)
```go ```go
func main() { func main() {
TEXT("EncodeInt", "func(lat, lng float64) uint64") TEXT("EncodeInt", NOSPLIT, "func(lat, lng float64) uint64")
Doc("EncodeInt computes the 64-bit integer geohash of (lat, lng).") Doc("EncodeInt computes the 64-bit integer geohash of (lat, lng).")
lat := Load(Param("lat"), XMM()) lat := Load(Param("lat"), XMM())
lng := Load(Param("lng"), XMM()) lng := Load(Param("lng"), XMM())

View File

@@ -8,7 +8,7 @@ Use `ReturnIndex` to reference unnamed return values. For example, the following
[embedmd]:# (asm.go go /.*TEXT.*Interval/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*Interval/ /RET.*/)
```go ```go
TEXT("Interval", "func(start, size uint64) (uint64, uint64)") TEXT("Interval", NOSPLIT, "func(start, size uint64) (uint64, uint64)")
Doc( Doc(
"Interval returns the (start, end) of an interval with the given start and size.", "Interval returns the (start, end) of an interval with the given start and size.",
"Demonstrates multiple unnamed return values.", "Demonstrates multiple unnamed return values.",
@@ -28,7 +28,7 @@ Named return values are referenced much the same as arguments. For example, the
[embedmd]:# (asm.go go /.*TEXT.*Butterfly/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*Butterfly/ /RET.*/)
```go ```go
TEXT("Butterfly", "func(x0, x1 float64) (y0, y1 float64)") TEXT("Butterfly", NOSPLIT, "func(x0, x1 float64) (y0, y1 float64)")
Doc( Doc(
"Butterfly performs a 2-dimensional butterfly operation: computes (x0+x1, x0-x1).", "Butterfly performs a 2-dimensional butterfly operation: computes (x0+x1, x0-x1).",
"Demonstrates multiple named return values.", "Demonstrates multiple named return values.",
@@ -53,7 +53,7 @@ The following code returns an array type.
[embedmd]:# (asm.go go /.*TEXT.*Septuple/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*Septuple/ /RET.*/)
```go ```go
TEXT("Septuple", "func(byte) [7]byte") TEXT("Septuple", NOSPLIT, "func(byte) [7]byte")
Doc( Doc(
"Septuple returns an array of seven of the given byte.", "Septuple returns an array of seven of the given byte.",
"Demonstrates returning array values.", "Demonstrates returning array values.",
@@ -69,7 +69,7 @@ Or a complex type:
[embedmd]:# (asm.go go /.*TEXT.*CriticalLine/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*CriticalLine/ /RET.*/)
```go ```go
TEXT("CriticalLine", "func(t float64) complex128") TEXT("CriticalLine", NOSPLIT, "func(t float64) complex128")
Doc( Doc(
"CriticalLine returns the complex value 0.5 + it on Riemann's critical line.", "CriticalLine returns the complex value 0.5 + it on Riemann's critical line.",
"Demonstrates returning complex values.", "Demonstrates returning complex values.",
@@ -86,7 +86,7 @@ You can even build a struct:
[embedmd]:# (asm.go go /.*TEXT.*NewStruct/ /RET.*/) [embedmd]:# (asm.go go /.*TEXT.*NewStruct/ /RET.*/)
```go ```go
TEXT("NewStruct", "func(w uint16, p [2]float64, q uint64) Struct") TEXT("NewStruct", NOSPLIT, "func(w uint16, p [2]float64, q uint64) Struct")
Doc( Doc(
"NewStruct initializes a Struct value.", "NewStruct initializes a Struct value.",
"Demonstrates returning struct values.", "Demonstrates returning struct values.",

View File

@@ -7,7 +7,7 @@ Compare to the [`crypto/sha1`](https://github.com/golang/go/blob/204a8f55dc2e0ac
[embedmd]:# (asm.go /func main/ /^}/) [embedmd]:# (asm.go /func main/ /^}/)
```go ```go
func main() { func main() {
TEXT("block", "func(h *[5]uint32, m []byte)") TEXT("block", 0, "func(h *[5]uint32, m []byte)")
Doc("block SHA-1 hashes the 64-byte message m into the running state h.") Doc("block SHA-1 hashes the 64-byte message m into the running state h.")
h := Mem{Base: Load(Param("h"), GP64())} h := Mem{Base: Load(Param("h"), GP64())}
m := Mem{Base: Load(Param("m").Base(), GP64())} m := Mem{Base: Load(Param("m").Base(), GP64())}

View File

@@ -5,7 +5,7 @@ Sum a slice of `uint64`s.
[embedmd]:# (asm.go go /func main/ /^}/) [embedmd]:# (asm.go go /func main/ /^}/)
```go ```go
func main() { func main() {
TEXT("Sum", "func(xs []uint64) uint64") TEXT("Sum", NOSPLIT, "func(xs []uint64) uint64")
Doc("Sum returns the sum of the elements in xs.") Doc("Sum returns the sum of the elements in xs.")
ptr := Load(Param("xs").Base(), GP64()) ptr := Load(Param("xs").Base(), GP64())
n := Load(Param("xs").Len(), GP64()) n := Load(Param("xs").Len(), GP64())