op: introduce CallOp

We'd like to improve the API of Flex, Stack and similar layouts
that use MacroOps internall. Unfortunately, the

  func (m MacroOp) Add(o *Ops)

method causes the MacroOp to be allocated on the heap, ruining the
nice garbage-free property of layouts.

Fortunately, layouts don't need the feature that caused the heap
allocation: invoking operation lists different than the current.

CallOp separates the invoke-different-list semantic from MacroOp,
in preparation for removing the feature from MacroOp.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-12-11 22:53:50 +01:00
parent 9114dbe759
commit 06217c5320
3 changed files with 58 additions and 1 deletions
+4 -1
View File
@@ -26,6 +26,7 @@ const (
TypeAux
TypeClip
TypeProfile
TypeCall
)
const (
@@ -47,6 +48,7 @@ const (
TypeAuxLen = 1
TypeClipLen = 1 + 4*4
TypeProfileLen = 1
TypeCallLen = 1
)
func (t OpType) Size() int {
@@ -69,12 +71,13 @@ func (t OpType) Size() int {
TypeAuxLen,
TypeClipLen,
TypeProfileLen,
TypeCallLen,
}[t-firstOpIndex]
}
func (t OpType) NumRefs() int {
switch t {
case TypeMacro, TypeKeyInput, TypePointerInput, TypeProfile:
case TypeMacro, TypeKeyInput, TypePointerInput, TypeProfile, TypeCall:
return 1
case TypeImage:
return 2