pragma

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

README

pragma

Apply compiler directives to avo functions.

The code generator uses the Pragma function to apply the //go:noescape directive to the Add function:

func main() {
	TEXT("Add", NOSPLIT, "func(z, x, y *uint64)")
	Pragma("noescape")
	Doc("Add adds the values at x and y and writes the result to z.")
	zptr := Mem{Base: Load(Param("z"), GP64())}
	xptr := Mem{Base: Load(Param("x"), GP64())}
	yptr := Mem{Base: Load(Param("y"), GP64())}
	x, y := GP64(), GP64()
	MOVQ(xptr, x)
	MOVQ(yptr, y)
	ADDQ(x, y)
	MOVQ(y, zptr)
	RET()
	Generate()
}

Note the directive is applied in the generated stub file:

// Add adds the values at x and y and writes the result to z.
//
//go:noescape
func

Documentation

Overview

Package pragma demonstrates the use of compiler directives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(z *uint64, x *uint64, y *uint64)

Add adds the values at x and y and writes the result to z.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL