aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/compiler.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-05-03 11:29:12 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-03 12:55:42 +0200
commit58ae5e18624eaaac79cab00e63d6f32c9bd64ee0 (patch)
tree00515dd9b2e461102e898930df00bc80400bf996 /pkg/compiler/compiler.go
parent5457883a514281287bbd81364c4e26e25828563d (diff)
prog: remove StructDesc
Remove StructDesc, KeyedStruct, StructKey and all associated logic/complexity in prog and pkg/compiler. We can now handle recursion more generically with the Ref type, and Dir/FieldName are not a part of the type anymore. This makes StructType/UnionType simpler and more natural. Reduces size of sys/linux/gen/amd64.go from 5201321 to 4180861 (-20%). Update #1580
Diffstat (limited to 'pkg/compiler/compiler.go')
-rw-r--r--pkg/compiler/compiler.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go
index f61d02036..55ddc1ba4 100644
--- a/pkg/compiler/compiler.go
+++ b/pkg/compiler/compiler.go
@@ -34,10 +34,9 @@ import (
// Prog is description compilation result.
type Prog struct {
- Resources []*prog.ResourceDesc
- Syscalls []*prog.Syscall
- StructDescs []*prog.KeyedStruct
- Types []prog.Type
+ Resources []*prog.ResourceDesc
+ Syscalls []*prog.Syscall
+ Types []prog.Type
// Set of unsupported syscalls/flags.
Unsupported map[string]bool
// Returned if consts was nil.
@@ -61,9 +60,8 @@ func createCompiler(desc *ast.Description, target *targets.Target, eh ast.ErrorH
strFlags: make(map[string]*ast.StrFlags),
used: make(map[string]bool),
usedTypedefs: make(map[string]bool),
- structDescs: make(map[prog.StructKey]*prog.StructDesc),
- structNodes: make(map[*prog.StructDesc]*ast.Struct),
structVarlen: make(map[string]bool),
+ structTypes: make(map[string]prog.Type),
builtinConsts: map[string]uint64{
"PTR_SIZE": target.PtrSize,
},
@@ -104,12 +102,11 @@ func Compile(desc *ast.Description, consts map[string]uint64, target *targets.Ta
return nil
}
syscalls := comp.genSyscalls()
- structs := comp.genStructDescs(syscalls)
- types := comp.generateTypes(syscalls, structs)
+ comp.layoutTypes(syscalls)
+ types := comp.generateTypes(syscalls)
prg := &Prog{
Resources: comp.genResources(),
Syscalls: syscalls,
- StructDescs: structs,
Types: types,
Unsupported: comp.unsupported,
}
@@ -139,9 +136,8 @@ type compiler struct {
used map[string]bool // contains used structs/resources
usedTypedefs map[string]bool
- structDescs map[prog.StructKey]*prog.StructDesc
- structNodes map[*prog.StructDesc]*ast.Struct
structVarlen map[string]bool
+ structTypes map[string]prog.Type
builtinConsts map[string]uint64
}