mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
compiler: implement volatile operations as compiler builtins
The long term goal is to remove the //go:volatile hack.
This commit is contained in:
committed by
Ron Evans
parent
3c2639ad55
commit
397b90753c
@@ -0,0 +1,34 @@
|
||||
// Package volatile provides definitions for volatile loads and stores. These
|
||||
// are implemented as compiler builtins.
|
||||
//
|
||||
// The load operations load a volatile value. The store operations store to a
|
||||
// volatile value. The compiler will emit exactly one load or store operation
|
||||
// when possible and will not reorder volatile operations. However, the compiler
|
||||
// may move other operations across load/store operations, so make sure that all
|
||||
// relevant loads/stores are done in a volatile way if this is a problem.
|
||||
//
|
||||
// These loads and stores are commonly used to read/write values from memory
|
||||
// mapped peripheral devices. They do not provide atomicity, use the sync/atomic
|
||||
// package for that.
|
||||
//
|
||||
// For more details: https://llvm.org/docs/LangRef.html#volatile-memory-accesses
|
||||
// and https://blog.regehr.org/archives/28.
|
||||
package volatile
|
||||
|
||||
// LoadUint8 loads the volatile value *addr.
|
||||
func LoadUint8(addr *uint8) (val uint8)
|
||||
|
||||
// LoadUint16 loads the volatile value *addr.
|
||||
func LoadUint16(addr *uint16) (val uint16)
|
||||
|
||||
// LoadUint32 loads the volatile value *addr.
|
||||
func LoadUint32(addr *uint32) (val uint32)
|
||||
|
||||
// StoreUint8 stores val to the volatile value *addr.
|
||||
func StoreUint8(addr *uint8, val uint8)
|
||||
|
||||
// StoreUint16 stores val to the volatile value *addr.
|
||||
func StoreUint16(addr *uint16, val uint16)
|
||||
|
||||
// StoreUint32 stores val to the volatile value *addr.
|
||||
func StoreUint32(addr *uint32, val uint32)
|
||||
Reference in New Issue
Block a user