diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-07-07 20:07:30 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-07-08 22:52:24 +0200 |
| commit | 306ca0571c5d906ce76df97bd1ea54f4e0e50240 (patch) | |
| tree | a579718e096c53dc5386f4af2fbabb3318eaf1ed /prog/encodingexec.go | |
| parent | 93213ec0d3c4522c8844a51b718eb56ce62f395b (diff) | |
prog, pkg/compiler: support fmt type
fmt type allows to convert intergers and resources
to string representation.
Diffstat (limited to 'prog/encodingexec.go')
| -rw-r--r-- | prog/encodingexec.go | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go index a162a7126..25e99e215 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -230,26 +230,27 @@ func (w *execContext) write(v uint64) { func (w *execContext) writeArg(arg Arg) { switch a := arg.(type) { case *ConstArg: - val, pidStride, bigEndian := a.Value() - w.writeConstArg(a.Size(), val, a.Type().BitfieldOffset(), a.Type().BitfieldLength(), - pidStride, bigEndian) + val, pidStride := a.Value() + typ := a.Type() + w.writeConstArg(a.Size(), val, typ.BitfieldOffset(), typ.BitfieldLength(), pidStride, typ.Format()) case *ResultArg: if a.Res == nil { - w.writeConstArg(a.Size(), a.Val, 0, 0, 0, false) + w.writeConstArg(a.Size(), a.Val, 0, 0, 0, a.Type().Format()) } else { info, ok := w.args[a.Res] if !ok { panic("no copyout index") } w.write(execArgResult) - w.write(a.Size()) + meta := a.Size() | uint64(a.Type().Format())<<8 + w.write(meta) w.write(info.Idx) w.write(a.OpDiv) w.write(a.OpAdd) w.write(a.Type().(*ResourceType).Default()) } case *PointerArg: - w.writeConstArg(a.Size(), w.target.PhysicalAddr(a), 0, 0, 0, false) + w.writeConstArg(a.Size(), w.target.PhysicalAddr(a), 0, 0, 0, FormatNative) case *DataArg: data := a.Data() w.write(execArgData) @@ -271,12 +272,9 @@ func (w *execContext) writeArg(arg Arg) { } } -func (w *execContext) writeConstArg(size, val, bfOffset, bfLength, pidStride uint64, bigEndian bool) { +func (w *execContext) writeConstArg(size, val, bfOffset, bfLength, pidStride uint64, bf BinaryFormat) { w.write(execArgConst) - meta := size | bfOffset<<16 | bfLength<<24 | pidStride<<32 - if bigEndian { - meta |= 1 << 8 - } + meta := size | uint64(bf)<<8 | bfOffset<<16 | bfLength<<24 | pidStride<<32 w.write(meta) w.write(val) } |
