github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/bits/uint64_arch_arm64_asm.s (about)

     1  // Copyright 2019 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  //go:build arm64
    16  // +build arm64
    17  
    18  TEXT ·TrailingZeros64(SB),$0-16
    19    MOVD  x+0(FP), R0
    20    RBIT  R0, R0
    21    CLZ   R0, R0        // return 64 if x == 0
    22    MOVD  R0, ret+8(FP)
    23    RET
    24  
    25  TEXT ·MostSignificantOne64(SB),$0-16
    26    MOVD  x+0(FP), R0
    27    CLZ   R0, R0        // return 64 if x == 0
    28    MOVD  $63, R1
    29    SUBS  R0, R1, R0    // ret = 63 - CLZ
    30    BPL   end
    31    MOVD  $64, R0       // x == 0
    32  end:
    33    MOVD  R0, ret+8(FP)
    34    RET