feat(amd64): floating-point immediates through a synthesised pool

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-21 02:04:44 +02:00
parent bfb7701db1
commit 29ac03468e
10 changed files with 761 additions and 41 deletions
+21 -1
View File
@@ -167,6 +167,7 @@ func AssembleFile(f *ast.File) (*Image, error) {
known[d.name] = true
}
link := &linkInfo{symbols: known, allowExternal: true}
poolSeen := map[string]bool{}
img := &Image{Symbols: map[string]int{}, SourcePath: f.Path}
textOff := map[string]int{}
@@ -180,7 +181,26 @@ func AssembleFile(f *ast.File) (*Image, error) {
if !ok {
continue
}
code, patches, labels, steps, lines, err := assemble(t, link)
code, patches, labels, steps, lines, pool, err := assemble(t, link)
if err != nil {
return nil, fmt.Errorf("%s: %w", t.Name.Name, err)
}
// The pooled floating-point constants join the declared data as
// read-only symbols, deduplicated across the file (the toolchain
// synthesises the same symbols into its rodata).
for _, entry := range pool {
if poolSeen[entry.name] {
continue
}
poolSeen[entry.name] = true
dataSyms = append(dataSyms, dataSym{
name: entry.name,
buf: entry.data,
size: len(entry.data),
rodata: true,
dupok: true,
})
}
if err != nil {
return nil, fmt.Errorf("%s: %w", t.Name.Name, err)
}