From 20c6855484620eda011e4e4002c6f7f272a878c4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 18 Dec 2019 18:30:39 +0100 Subject: prog: refactor bitfields representation All callers of BitfieldMiddle just want static size (0 for middle). Make it so: Size for middle bitfields just returns 0. Removes lots of if's. Introduce Type.UnitSize, which now holds the underlying type for bitfields. This will be needed to fix #1542 b/c even if UnitSize=4 for last bitfield Size can be anywhere from 0 to 4 (not necessary equal to UnitSize due to overlapping). --- prog/encodingexec.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index 2d2f02e57..2e69f2116 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -133,7 +133,7 @@ func (w *execContext) writeCopyin(c *Call) { return } typ := arg.Type() - if typ.Dir() == DirOut || IsPad(typ) || arg.Size() == 0 { + if typ.Dir() == DirOut || IsPad(typ) || (arg.Size() == 0 && !typ.IsBitfield()) { return } w.write(execInstrCopyin) @@ -236,7 +236,7 @@ func (w *execContext) writeArg(arg Arg) { case *ConstArg: val, pidStride := a.Value() typ := a.Type() - w.writeConstArg(a.Size(), val, typ.BitfieldOffset(), typ.BitfieldLength(), pidStride, typ.Format()) + w.writeConstArg(typ.UnitSize(), val, typ.BitfieldOffset(), typ.BitfieldLength(), pidStride, typ.Format()) case *ResultArg: if a.Res == nil { w.writeConstArg(a.Size(), a.Val, 0, 0, 0, a.Type().Format()) -- cgit mrf-deployment