1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * The methods that are intrinsified in Long and their expected redefined implementations.
19  */
20 class RedefinedLongIntrinsics {
21   // Intrinsic! Do something cool. Return i + 1
highestOneBit(long i)22   public static long highestOneBit(long i) {
23     return i + 1;
24   }
25 
26   // Intrinsic! Do something cool. Return i - 1
lowestOneBit(long i)27   public static long lowestOneBit(long i) {
28     return i - 1;
29   }
30 
31   // Intrinsic! Do something cool. Return i + i
numberOfLeadingZeros(long i)32   public static int numberOfLeadingZeros(long i) {
33     return (int)(i + i);
34   }
35 
36   // Intrinsic! Do something cool. Return i & (i >>> 1);
numberOfTrailingZeros(long i)37   public static int numberOfTrailingZeros(long i) {
38     return (int)(i & (i >>> 1));
39   }
40 
41   // Intrinsic! Do something cool. Return 5
bitCount(long i)42   public static int bitCount(long i) {
43     return 5;
44   }
45 
46   // Intrinsic! Do something cool. Return i
rotateLeft(long i, int distance)47   public static long rotateLeft(long i, int distance) {
48     return i;
49   }
50 
51   // Intrinsic! Do something cool. Return 10 * i
rotateRight(long i, int distance)52   public static long rotateRight(long i, int distance) {
53     return 10 * i;
54   }
55 
56   // Intrinsic! Do something cool. Return -i
reverse(long i)57   public static long reverse(long i) {
58     return -i;
59   }
60 
61   // Intrinsic! Do something cool. Return 0
signum(long i)62   public static int signum(long i) {
63     return 0;
64   }
65 
66   // Intrinsic! Do something cool. Return 0
reverseBytes(long i)67   public static long reverseBytes(long i) {
68     return 0;
69   }
70 }
71