ast,build: allow setting data attributes

Previously GLOBL/DATA attributes are set to RODATA. This diff removes
that default and allows them to be set through the DataAttributes
context method.

Updates #2
This commit is contained in:
Michael McLoughlin
2018-12-31 19:04:14 -08:00
parent f2315d539c
commit 816fa4c0e6
8 changed files with 19 additions and 11 deletions

View File

@@ -5,12 +5,13 @@ package main
import (
"math"
"github.com/mmcloughlin/avo"
. "github.com/mmcloughlin/avo/build"
. "github.com/mmcloughlin/avo/operand"
)
func main() {
bytes := GLOBL("bytes")
bytes := GLOBL("bytes", avo.RODATA|avo.NOPTR)
DATA(0, U64(0x0011223344556677))
DATA(8, String("strconst"))
DATA(16, F32(math.Pi))

View File

@@ -10,7 +10,7 @@ DATA bytes<>+32(SB)/4, $0x00112233
DATA bytes<>+36(SB)/2, $0x4455
DATA bytes<>+38(SB)/1, $0x66
DATA bytes<>+39(SB)/1, $0x77
GLOBL bytes<>(SB), RODATA, $40
GLOBL bytes<>(SB), RODATA|NOPTR, $40
// func DataAt(i int) byte
TEXT ·DataAt(SB), $0-9

View File

@@ -22,13 +22,13 @@ TEXT ·EncodeInt(SB), $0-24
RET
DATA reciprocal180<>(SB)/8, $(0.005555555555555556)
GLOBL reciprocal180<>(SB), RODATA, $8
GLOBL reciprocal180<>(SB), RODATA|NOPTR, $8
DATA onepointfive<>(SB)/8, $(1.5)
GLOBL onepointfive<>(SB), RODATA, $8
GLOBL onepointfive<>(SB), RODATA|NOPTR, $8
DATA reciprocal360<>(SB)/8, $(0.002777777777777778)
GLOBL reciprocal360<>(SB), RODATA, $8
GLOBL reciprocal360<>(SB), RODATA|NOPTR, $8
DATA mask<>(SB)/8, $0x5555555555555555
GLOBL mask<>(SB), RODATA, $8
GLOBL mask<>(SB), RODATA|NOPTR, $8

View File

@@ -44,7 +44,7 @@ TEXT ·CriticalLine(SB), $0-24
RET
DATA half<>(SB)/8, $(0.5)
GLOBL half<>(SB), RODATA, $8
GLOBL half<>(SB), RODATA|NOPTR, $8
// func NewStruct(w uint16, p [2]float64, q uint64) Struct
TEXT ·NewStruct(SB), $0-64