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 LSmaliTests; 16 .super Ljava/lang/Object; 17 18 # static fields 19 .field public static booleanField:Z 20 21 .method static constructor <clinit>()V 22 .registers 1 23 24 .prologue 25 const/4 v0, 0x1 26 27 # booleanField = true 28 sput-boolean v0, LSmaliTests;->booleanField:Z 29 30 return-void 31 .end method 32 33 ## CHECK-START: long SmaliTests.booleanToLong(boolean) builder (after) 34 ## CHECK-DAG: <<Arg:z\d+>> ParameterValue 35 ## CHECK-DAG: <<Zero:i\d+>> IntConstant 0 36 ## CHECK-DAG: <<One:i\d+>> IntConstant 1 37 ## CHECK-DAG: <<Cond:z\d+>> Equal [<<Arg>>,<<Zero>>] 38 ## CHECK-DAG: If [<<Cond>>] 39 ## CHECK-DAG: <<Phi:i\d+>> Phi [<<One>>,<<Zero>>] 40 ## CHECK-DAG: <<IToJ:j\d+>> TypeConversion [<<Phi>>] 41 ## CHECK-DAG: Return [<<IToJ>>] 42 43 ## CHECK-START: long SmaliTests.booleanToLong(boolean) select_generator (after) 44 ## CHECK-DAG: <<Arg:z\d+>> ParameterValue 45 ## CHECK-DAG: <<Zero:i\d+>> IntConstant 0 46 ## CHECK-DAG: <<One:i\d+>> IntConstant 1 47 ## CHECK-DAG: <<Sel:i\d+>> Select [<<Zero>>,<<One>>,<<Arg>>] 48 ## CHECK-DAG: <<IToJ:j\d+>> TypeConversion [<<Sel>>] 49 ## CHECK-DAG: Return [<<IToJ>>] 50 51 ## CHECK-START: long SmaliTests.booleanToLong(boolean) instruction_simplifier$after_bce (after) 52 ## CHECK-DAG: <<Arg:z\d+>> ParameterValue 53 ## CHECK-DAG: <<ZToJ:j\d+>> TypeConversion [<<Arg>>] 54 ## CHECK-DAG: Return [<<ZToJ>>] 55 .method public static booleanToLong(Z)J 56 .registers 3 57 .param p0, "b" # Z 58 .prologue 59 60 # return b ? 1 : 0; 61 if-eqz p0, :b_is_zero 62 63 # :b_is_one 64 const/4 v0, 0x1 65 66 :l_return 67 int-to-long v0, v0 68 return-wide v0 69 70 :b_is_zero 71 const/4 v0, 0x0 72 goto :l_return 73 .end method 74 75 ## CHECK-START: int SmaliTests.longToIntOfBoolean() builder (after) 76 ## CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod 77 ## CHECK-DAG: <<Sget:z\d+>> StaticFieldGet 78 ## CHECK-DAG: <<ZToJ:j\d+>> InvokeStaticOrDirect [<<Sget>>,<<Method>>] 79 ## CHECK-DAG: <<JToI:i\d+>> TypeConversion [<<ZToJ>>] 80 ## CHECK-DAG: Return [<<JToI>>] 81 82 ## CHECK-START: int SmaliTests.longToIntOfBoolean() inliner (after) 83 ## CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod 84 ## CHECK-DAG: <<Zero:i\d+>> IntConstant 0 85 ## CHECK-DAG: <<One:i\d+>> IntConstant 1 86 ## CHECK-DAG: <<Sget:z\d+>> StaticFieldGet 87 ## CHECK-DAG: If [<<Sget>>] 88 ## CHECK-DAG: <<Phi:i\d+>> Phi [<<One>>,<<Zero>>] 89 ## CHECK-DAG: <<IToJ:j\d+>> TypeConversion [<<Phi>>] 90 ## CHECK-DAG: <<JToI:i\d+>> TypeConversion [<<IToJ>>] 91 ## CHECK-DAG: Return [<<JToI>>] 92 93 ## CHECK-START: int SmaliTests.longToIntOfBoolean() select_generator (after) 94 ## CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod 95 ## CHECK-DAG: <<Zero:i\d+>> IntConstant 0 96 ## CHECK-DAG: <<One:i\d+>> IntConstant 1 97 ## CHECK-DAG: <<Sget:z\d+>> StaticFieldGet 98 ## CHECK-DAG: <<Sel:i\d+>> Select [<<Zero>>,<<One>>,<<Sget>>] 99 ## CHECK-DAG: <<IToJ:j\d+>> TypeConversion [<<Sel>>] 100 ## CHECK-DAG: <<JToI:i\d+>> TypeConversion [<<IToJ>>] 101 ## CHECK-DAG: Return [<<JToI>>] 102 103 ## CHECK-START: int SmaliTests.longToIntOfBoolean() instruction_simplifier$after_bce (after) 104 ## CHECK-DAG: <<Method:[ij]\d+>> CurrentMethod 105 ## CHECK-DAG: <<Sget:z\d+>> StaticFieldGet 106 ## CHECK-DAG: Return [<<Sget>>] 107 .method public static longToIntOfBoolean()I 108 .registers 3 109 .prologue 110 111 # long l = booleanToLong(booleanField); 112 sget-boolean v2, LSmaliTests;->booleanField:Z 113 invoke-static {v2}, LSmaliTests;->booleanToLong(Z)J 114 move-result-wide v0 115 116 # return (int) l; 117 long-to-int v2, v0 118 return v2 119 .end method 120