mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 21:13:39 +00:00
all: change special type __volatile to pragma //go:volatile
This is one step towards removing unnecessary special casts in most cases. It is also part of removing as much magic as possible from the compiler (the pragma is explicit, the special name is not).
This commit is contained in:
@@ -142,11 +142,10 @@ package {pkgName}
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// Magic type name for the compiler.
|
||||
type __volatile uint8
|
||||
|
||||
// Export this magic type name.
|
||||
type RegValue = __volatile
|
||||
// Special type that causes loads/stores to be volatile (necessary for
|
||||
// memory-mapped registers).
|
||||
//go:volatile
|
||||
type RegValue uint8
|
||||
|
||||
// Some information about this device.
|
||||
const (
|
||||
@@ -169,7 +168,7 @@ const (
|
||||
out.write('\n\t// {description}\n'.format(**peripheral))
|
||||
for register in peripheral['registers']:
|
||||
for variant in register['variants']:
|
||||
out.write('\t{name} = (*__volatile)(unsafe.Pointer(uintptr(0x{address:x})))\n'.format(**variant))
|
||||
out.write('\t{name} = (*RegValue)(unsafe.Pointer(uintptr(0x{address:x})))\n'.format(**variant))
|
||||
out.write(')\n')
|
||||
|
||||
for peripheral in device.peripherals:
|
||||
|
||||
@@ -216,11 +216,10 @@ package {pkgName}
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// Magic type name for the compiler.
|
||||
type __volatile uint32
|
||||
|
||||
// Export this magic type name.
|
||||
type RegValue = __volatile
|
||||
// Special type that causes loads/stores to be volatile (necessary for
|
||||
// memory-mapped registers).
|
||||
//go:volatile
|
||||
type RegValue uint32
|
||||
|
||||
// Some information about this device.
|
||||
const (
|
||||
@@ -255,14 +254,14 @@ const (
|
||||
if address < register['address']:
|
||||
numSkip = (register['address'] - address) // 4
|
||||
if numSkip == 1:
|
||||
out.write('\t_padding{padNumber} __volatile\n'.format(padNumber=padNumber))
|
||||
out.write('\t_padding{padNumber} RegValue\n'.format(padNumber=padNumber))
|
||||
else:
|
||||
out.write('\t_padding{padNumber} [{num}]__volatile\n'.format(padNumber=padNumber, num=numSkip))
|
||||
out.write('\t_padding{padNumber} [{num}]RegValue\n'.format(padNumber=padNumber, num=numSkip))
|
||||
padNumber += 1
|
||||
|
||||
regType = '__volatile'
|
||||
regType = 'RegValue'
|
||||
if register['array'] is not None:
|
||||
regType = '[{}]__volatile'.format(register['array'])
|
||||
regType = '[{}]RegValue'.format(register['array'])
|
||||
out.write('\t{name} {regType}\n'.format(**register, regType=regType))
|
||||
|
||||
# next address
|
||||
|
||||
Reference in New Issue
Block a user