github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/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  // +build arm64
    16  
    17  TEXT ·TrailingZeros64(SB),$0-16
    18    MOVD  x+0(FP), R0
    19    RBIT  R0, R0
    20    CLZ   R0, R0        // return 64 if x == 0
    21    MOVD  R0, ret+8(FP)
    22    RET
    23  
    24  TEXT ·MostSignificantOne64(SB),$0-16
    25    MOVD  x+0(FP), R0
    26    CLZ   R0, R0        // return 64 if x == 0
    27    MOVD  $63, R1
    28    SUBS  R0, R1, R0    // ret = 63 - CLZ
    29    BPL   end
    30    MOVD  $64, R0       // x == 0
    31  end:
    32    MOVD  R0, ret+8(FP)
    33    RET