github.com/bir3/gocompiler@v0.9.2202/src/xvendor/golang.org/x/arch/arm64/arm64asm/condition_util.go (about)

     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 arm64asm
     6  
     7  func extract_bit(value, bit uint32) uint32 {
     8  	return (value >> bit) & 1
     9  }
    10  
    11  func bfxpreferred_4(sf, opc1, imms, immr uint32) bool {
    12  	if imms < immr {
    13  		return false
    14  	}
    15  	if (imms>>5 == sf) && (imms&0x1f == 0x1f) {
    16  		return false
    17  	}
    18  	if immr == 0 {
    19  		if sf == 0 && (imms == 7 || imms == 15) {
    20  			return false
    21  		}
    22  		if sf == 1 && opc1 == 0 && (imms == 7 ||
    23  			imms == 15 || imms == 31) {
    24  			return false
    25  		}
    26  	}
    27  	return true
    28  }
    29  
    30  func move_wide_preferred_4(sf, N, imms, immr uint32) bool {
    31  	if sf == 1 && N != 1 {
    32  		return false
    33  	}
    34  	if sf == 0 && !(N == 0 && ((imms>>5)&1) == 0) {
    35  		return false
    36  	}
    37  	if imms < 16 {
    38  		return (-immr)%16 <= (15 - imms)
    39  	}
    40  	width := uint32(32)
    41  	if sf == 1 {
    42  		width = uint32(64)
    43  	}
    44  	if imms >= (width - 15) {
    45  		return (immr % 16) <= (imms - (width - 15))
    46  	}
    47  	return false
    48  }
    49  
    50  type sys uint8
    51  
    52  const (
    53  	sys_AT sys = iota
    54  	sys_DC
    55  	sys_IC
    56  	sys_TLBI
    57  	sys_SYS
    58  )
    59  
    60  func sys_op_4(op1, crn, crm, op2 uint32) sys {
    61  	sysInst := sysInstFields{uint8(op1), uint8(crn), uint8(crm), uint8(op2)}
    62  	return sysInst.getType()
    63  }
    64  
    65  func is_zero(x uint32) bool {
    66  	return x == 0
    67  }
    68  
    69  func is_ones_n16(x uint32) bool {
    70  	return x == 0xffff
    71  }
    72  
    73  func bit_count(x uint32) uint8 {
    74  	var count uint8
    75  	for count = 0; x > 0; x >>= 1 {
    76  		if (x & 1) == 1 {
    77  			count++
    78  		}
    79  	}
    80  	return count
    81  }