github.com/tencent/goom@v1.0.1/internal/arch/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  // nolint
     8  func extract_bit(value, bit uint32) uint32 {
     9  	return (value >> bit) & 1
    10  }
    11  
    12  // nolint
    13  func bfxpreferred_4(sf, opc1, imms, immr uint32) bool {
    14  	if imms < immr {
    15  		return false
    16  	}
    17  	if (imms>>5 == sf) && (imms&0x1f == 0x1f) {
    18  		return false
    19  	}
    20  	if immr == 0 {
    21  		if sf == 0 && (imms == 7 || imms == 15) {
    22  			return false
    23  		}
    24  		if sf == 1 && opc1 == 0 && (imms == 7 ||
    25  			imms == 15 || imms == 31) {
    26  			return false
    27  		}
    28  	}
    29  	return true
    30  }
    31  
    32  // nolint
    33  func move_wide_preferred_4(sf, N, imms, immr uint32) bool {
    34  	if sf == 1 && N != 1 {
    35  		return false
    36  	}
    37  	if sf == 0 && !(N == 0 && ((imms>>5)&1) == 0) {
    38  		return false
    39  	}
    40  	if imms < 16 {
    41  		return (-immr)%16 <= (15 - imms)
    42  	}
    43  	width := uint32(32)
    44  	if sf == 1 {
    45  		width = uint32(64)
    46  	}
    47  	if imms >= (width - 15) {
    48  		return (immr % 16) <= (imms - (width - 15))
    49  	}
    50  	return false
    51  }
    52  
    53  // Sys sys
    54  type Sys uint8
    55  
    56  // nolint
    57  const (
    58  	Sys_AT Sys = iota
    59  	Sys_DC
    60  	Sys_IC
    61  	Sys_TLBI
    62  	Sys_SYS
    63  )
    64  
    65  // nolint
    66  func sys_op_4(op1, crn, crm, op2 uint32) Sys {
    67  	// TODO: system instruction
    68  	return Sys_SYS
    69  }
    70  
    71  // nolint
    72  func is_zero(x uint32) bool {
    73  	return x == 0
    74  }
    75  
    76  // nolint
    77  func is_ones_n16(x uint32) bool {
    78  	return x == 0xffff
    79  }
    80  
    81  // nolint
    82  func bit_count(x uint32) uint8 {
    83  	var count uint8
    84  	for count = 0; x > 0; x >>= 1 {
    85  		if (x & 1) == 1 {
    86  			count++
    87  		}
    88  	}
    89  	return count
    90  }