Debian Codegraph @

examples/pragma/README.md

raw symbols SCIP
1 # pragma
2
3 Apply [compiler directives](https://golang.org/pkg/cmd/compile/#hdr-Compiler_Directives) to `avo` functions.
4
5 The [code generator](asm.go) uses the `Pragma` function to apply the `//go:noescape` directive to the `Add` function:
6
7 [embedmd]:# (asm.go go /func main/ /^}/)
8 ```go
9 func main() {
10 TEXT("Add", NOSPLIT, "func(z, x, y *uint64)")
11 Pragma("noescape")
12 Doc("Add adds the values at x and y and writes the result to z.")
13 zptr := Mem{Base: Load(Param("z"), GP64())}
14 xptr := Mem{Base: Load(Param("x"), GP64())}
15 yptr := Mem{Base: Load(Param("y"), GP64())}
16 x, y := GP64(), GP64()
17 MOVQ(xptr, x)
18 MOVQ(yptr, y)
19 ADDQ(x, y)
20 MOVQ(y, zptr)
21 RET()
22 Generate()
23 }
24 ```
25
26 Note the directive is applied in the generated stub file:
27
28 [embedmd]:# (stub.go go /\/\/ Add/ /func/)
29 ```go
30 // Add adds the values at x and y and writes the result to z.
31 //
32 //go:noescape
33 func
34 ```