Home | History | Annotate | Download | only in x86
      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 
      5 package x86
      6 
      7 type argList [6]uint8
      8 
      9 type ytab struct {
     10 	zcase   uint8
     11 	zoffset uint8
     12 
     13 	// Last arg is usually destination.
     14 	// For unary instructions unaryDst is used to determine
     15 	// if single argument is a source or destination.
     16 	args argList
     17 }
     18 
     19 // Returns true if yt is compatible with args.
     20 //
     21 // Elements from args and yt.args are used to
     22 // to index ycover table like `ycover[args[i]+yt.args[i]]`.
     23 // This means that args should contain values that already
     24 // multiplied by Ymax.
     25 func (yt *ytab) match(args []int) bool {
     26 	// Trailing Yxxx check is required to avoid a case
     27 	// where shorter arg list is matched.
     28 	// If we had exact yt.args length, it could be `yt.argc != len(args)`.
     29 	if len(args) < len(yt.args) && yt.args[len(args)] != Yxxx {
     30 		return false
     31 	}
     32 
     33 	for i := range args {
     34 		if ycover[args[i]+int(yt.args[i])] == 0 {
     35 			return false
     36 		}
     37 	}
     38 
     39 	return true
     40 }
     41