Home | History | Annotate | Download | only in smali
      1 # Copyright (C) 2017 The Android Open Source Project
      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 .class public LSmali;
     16 .super Ljava/lang/Object;
     17 
     18 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) intrinsics_recognition (after)
     19 ##  CHECK-DAG:     <<Method:[ij]\d+>> CurrentMethod
     20 ##  CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
     21 ##  CHECK-DAG:     <<One:i\d+>>    IntConstant 1
     22 ##  CHECK-DAG:     <<PhiX:i\d+>>   Phi [<<One>>,<<Zero>>]
     23 ##  CHECK-DAG:     <<PhiY:i\d+>>   Phi [<<One>>,<<Zero>>]
     24 ##  CHECK-DAG:     <<Result:i\d+>> InvokeStaticOrDirect [<<PhiX>>,<<PhiY>>,<<Method>>] intrinsic:IntegerCompare
     25 ##  CHECK-DAG:                     Return [<<Result>>]
     26 
     27 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) instruction_simplifier (after)
     28 ##  CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
     29 ##  CHECK-DAG:     <<One:i\d+>>    IntConstant 1
     30 ##  CHECK-DAG:     <<PhiX:i\d+>>   Phi [<<One>>,<<Zero>>]
     31 ##  CHECK-DAG:     <<PhiY:i\d+>>   Phi [<<One>>,<<Zero>>]
     32 ##  CHECK-DAG:     <<Result:i\d+>> Compare [<<PhiX>>,<<PhiY>>]
     33 ##  CHECK-DAG:                     Return [<<Result>>]
     34 
     35 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) instruction_simplifier (after)
     36 ##  CHECK-NOT:                     InvokeStaticOrDirect
     37 
     38 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) select_generator (after)
     39 ##  CHECK:         <<ArgX:z\d+>>   ParameterValue
     40 ##  CHECK:         <<ArgY:z\d+>>   ParameterValue
     41 ##  CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
     42 ##  CHECK-DAG:     <<One:i\d+>>    IntConstant 1
     43 ##  CHECK-DAG:     <<SelX:i\d+>>   Select [<<Zero>>,<<One>>,<<ArgX>>]
     44 ##  CHECK-DAG:     <<SelY:i\d+>>   Select [<<Zero>>,<<One>>,<<ArgY>>]
     45 ##  CHECK-DAG:     <<Result:i\d+>> Compare [<<SelX>>,<<SelY>>]
     46 ##  CHECK-DAG:                     Return [<<Result>>]
     47 
     48 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) select_generator (after)
     49 ##  CHECK-NOT:                     Phi
     50 
     51 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) instruction_simplifier$after_bce (after)
     52 ##  CHECK:         <<ArgX:z\d+>>   ParameterValue
     53 ##  CHECK:         <<ArgY:z\d+>>   ParameterValue
     54 ##  CHECK-DAG:     <<Result:i\d+>> Compare [<<ArgX>>,<<ArgY>>]
     55 ##  CHECK-DAG:                     Return [<<Result>>]
     56 
     57 ##  CHECK-START: int Smali.compareBooleans(boolean, boolean) instruction_simplifier$after_bce (after)
     58 ##  CHECK-NOT:                     Select
     59 
     60 #   Note: This test has been written in smali (in addition to the source version) because Dexers
     61 #         such as D8 can perform the same type of intrinsic replacements.
     62 .method public static compareBooleans(ZZ)I
     63     # return Integer.compare((x ? 1 : 0), (y ? 1 : 0));
     64     .registers 5
     65     const/4 v0, 0x1
     66 
     67     const/4 v1, 0x0
     68 
     69     if-eqz p0, :cond_c
     70 
     71     move v2, v0
     72 
     73     :goto_5
     74     if-eqz p1, :cond_e
     75 
     76     :goto_7
     77     invoke-static {v2, v0}, Ljava/lang/Integer;->compare(II)I
     78 
     79     move-result v0
     80 
     81     return v0
     82 
     83     :cond_c
     84     move v2, v1
     85 
     86     goto :goto_5
     87 
     88     :cond_e
     89     move v0, v1
     90 
     91     goto :goto_7
     92 .end method
     93