podman
44 строки · 1.2 Кб
1// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package x86
6
7// argListMax specifies upper arg count limit expected to be carried by obj.Prog.
8// Max len(obj.Prog.RestArgs) can be inferred from this to be 4.
9const argListMax int = 6
10
11type argList [argListMax]uint8
12
13type ytab struct {
14zcase uint8
15zoffset uint8
16
17// Last arg is usually destination.
18// For unary instructions unaryDst is used to determine
19// if single argument is a source or destination.
20args argList
21}
22
23// Returns true if yt is compatible with args.
24//
25// Elements from args and yt.args are used
26// to index ycover table like `ycover[args[i]+yt.args[i]]`.
27// This means that args should contain values that already
28// multiplied by Ymax.
29func (yt *ytab) match(args []int) bool {
30// Trailing Yxxx check is required to avoid a case
31// where shorter arg list is matched.
32// If we had exact yt.args length, it could be `yt.argc != len(args)`.
33if len(args) < len(yt.args) && yt.args[len(args)] != Yxxx {
34return false
35}
36
37for i := range args {
38if ycover[args[i]+int(yt.args[i])] == 0 {
39return false
40}
41}
42
43return true
44}
45