From e54e9781a4e043b3140b0c908ba4f4e469fd317e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 26 Apr 2020 14:14:14 +0200 Subject: prog: remove Dir from Type Having Dir is Type is handy, but forces us to duplicate lots of types. E.g. if a struct is referenced as both in and out, then we need to have 2 copies and 2 copies of structs/types it includes. If also prevents us from having the struct type as struct identity (because we can have up to 3 of them). Revert to the old way we used to do it: propagate Dir as we walk syscall arguments. This moves lots of dir passing from pkg/compiler to prog package. Now Arg contains the dir, so once we build the tree, we can use dirs as before. Reduces size of sys/linux/gen/amd64.go from 6058336 to 5661150 (-6.6%). Update #1580 --- pkg/compiler/compiler.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'pkg/compiler/compiler.go') diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 7316b4d4c..8e5afddde 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -249,14 +249,13 @@ func (comp *compiler) getTypeDesc(t *ast.Type) *typeDesc { return nil } -func (comp *compiler) getArgsBase(t *ast.Type, field string, dir prog.Dir, isArg bool) ( - *typeDesc, []*ast.Type, prog.IntTypeCommon) { +func (comp *compiler) getArgsBase(t *ast.Type, field string, isArg bool) (*typeDesc, []*ast.Type, prog.IntTypeCommon) { desc := comp.getTypeDesc(t) if desc == nil { panic(fmt.Sprintf("no type desc for %#v", *t)) } args, opt := removeOpt(t) - com := genCommon(t.Ident, field, sizeUnassigned, dir, opt != nil) + com := genCommon(t.Ident, field, sizeUnassigned, opt != nil) base := genIntCommon(com, 0, false) if desc.NeedBase { base.TypeSize = comp.ptrSize @@ -306,7 +305,7 @@ func (comp *compiler) foreachType(n0 ast.Node, func (comp *compiler) foreachSubType(t *ast.Type, isArg bool, cb func(*ast.Type, *typeDesc, []*ast.Type, prog.IntTypeCommon)) { - desc, args, base := comp.getArgsBase(t, "", prog.DirIn, isArg) + desc, args, base := comp.getArgsBase(t, "", isArg) cb(t, desc, args, base) for i, arg := range args { if desc.Args[i].Type == typeArgType { -- cgit mrf-deployment