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 .source "Smali.java"
     18 
     19 ##  CHECK-START: int Smali.InlineWithControlFlow(boolean) inliner (before)
     20 ##  CHECK-DAG:     <<Const1:i\d+>> IntConstant 1
     21 ##  CHECK-DAG:     <<Const3:i\d+>> IntConstant 3
     22 ##  CHECK-DAG:     <<Const5:i\d+>> IntConstant 5
     23 ##  CHECK-DAG:     <<Add:i\d+>>    InvokeStaticOrDirect [<<Const1>>,<<Const3>>{{(,[ij]\d+)?}}]
     24 ##  CHECK-DAG:     <<Sub:i\d+>>    InvokeStaticOrDirect [<<Const5>>,<<Const3>>{{(,[ij]\d+)?}}]
     25 ##  CHECK-DAG:     <<Phi:i\d+>>    Phi [<<Add>>,<<Sub>>]
     26 ##  CHECK-DAG:                     Return [<<Phi>>]
     27 
     28 ##  CHECK-START: int Smali.InlineWithControlFlow(boolean) inliner (after)
     29 ##  CHECK-DAG:     <<Const4:i\d+>> IntConstant 4
     30 ##  CHECK-DAG:     <<Const2:i\d+>> IntConstant 2
     31 ##  CHECK-DAG:     <<Phi:i\d+>>    Phi [<<Const4>>,<<Const2>>]
     32 ##  CHECK-DAG:                     Return [<<Phi>>]
     33 .method public static InlineWithControlFlow(Z)I
     34 
     35     # int x, const1, const3, const5;
     36     # const1 = 1;
     37     # const3 = 3;
     38     # const5 = 5;
     39     # if (cond) {
     40     #   x = returnAdd(const1, const3);
     41     # } else {
     42     #   x = returnSub(const5, const3);
     43     # }
     44     # return x;
     45 
     46     .registers 5
     47     .param p0, "cond"    # Z
     48 
     49     .prologue
     50     const/4 v0, 0x1
     51 
     52     .local v0, "const1":I
     53     const/4 v1, 0x3
     54 
     55     .local v1, "const3":I
     56     const/4 v2, 0x5
     57 
     58     .local v2, "const5":I
     59     if-eqz p0, :cond_a
     60 
     61     invoke-static {v0, v1}, LSmali;->returnAdd(II)I
     62 
     63     move-result v3
     64 
     65     .local v3, "x":I
     66     :goto_9
     67     return v3
     68 
     69     .end local v3    # "x":I
     70     :cond_a
     71     invoke-static {v2, v1}, LSmali;->returnSub(II)I
     72 
     73     move-result v3
     74 
     75     .restart local v3    # "x":I
     76     goto :goto_9
     77 .end method
     78 
     79 .method private static returnAdd(II)I
     80     .registers 3
     81     .param p0, "a"    # I
     82     .param p1, "b"    # I
     83 
     84     add-int v0, p0, p1
     85 
     86     return v0
     87 .end method
     88 
     89 .method private static returnSub(II)I
     90     .registers 3
     91     .param p0, "a"    # I
     92     .param p1, "b"    # I
     93 
     94     sub-int v0, p0, p1
     95 
     96     return v0
     97 .end method
     98