# Copyright (C) 2017 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. .class public LSmaliTests; .super Ljava/lang/Object; # static fields .field public static booleanField:Z .method static constructor ()V .registers 1 .prologue const/4 v0, 0x1 # booleanField = true sput-boolean v0, LSmaliTests;->booleanField:Z return-void .end method ## CHECK-START: byte SmaliTests.booleanToByte(boolean) builder (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Equal [<>,<>] ## CHECK-DAG: If [<>] ## CHECK-DAG: <> Phi [<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: byte SmaliTests.booleanToByte(boolean) select_generator (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Select [<>,<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: byte SmaliTests.booleanToByte(boolean) instruction_simplifier$after_bce (after) ## CHECK: <> ParameterValue ## CHECK-DAG: Return [<>] .method static booleanToByte(Z)B .registers 2 if-eqz p0, :cond_5 const/4 v0, 0x1 :goto_3 int-to-byte v0, v0 return v0 :cond_5 const/4 v0, 0x0 goto :goto_3 .end method ## CHECK-START: short SmaliTests.booleanToShort(boolean) builder (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Equal [<>,<>] ## CHECK-DAG: If [<>] ## CHECK-DAG: <> Phi [<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: short SmaliTests.booleanToShort(boolean) select_generator (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Select [<>,<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: short SmaliTests.booleanToShort(boolean) instruction_simplifier$after_bce (after) ## CHECK: <> ParameterValue ## CHECK-DAG: Return [<>] .method static booleanToShort(Z)S .registers 2 if-eqz p0, :cond_5 const/4 v0, 0x1 :goto_3 int-to-short v0, v0 return v0 :cond_5 const/4 v0, 0x0 goto :goto_3 .end method ## CHECK-START: char SmaliTests.booleanToChar(boolean) builder (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Equal [<>,<>] ## CHECK-DAG: If [<>] ## CHECK-DAG: <> Phi [<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: char SmaliTests.booleanToChar(boolean) select_generator (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Select [<>,<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: char SmaliTests.booleanToChar(boolean) instruction_simplifier$after_bce (after) ## CHECK: <> ParameterValue ## CHECK-DAG: Return [<>] .method static booleanToChar(Z)C .registers 2 if-eqz p0, :cond_5 const/4 v0, 0x1 :goto_3 int-to-char v0, v0 return v0 :cond_5 const/4 v0, 0x0 goto :goto_3 .end method ## CHECK-START: int SmaliTests.booleanToInt(boolean) builder (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Equal [<>,<>] ## CHECK-DAG: If [<>] ## CHECK-DAG: <> Phi [<>,<>] ## CHECK-DAG: Return [<>] ## CHECK-START: int SmaliTests.booleanToInt(boolean) select_generator (after) ## CHECK: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Select [<>,<>,<>] ## CHECK-DAG: Return [<>] ## CHECK-START: int SmaliTests.booleanToInt(boolean) instruction_simplifier$after_bce (after) ## CHECK: <> ParameterValue ## CHECK-DAG: Return [<>] .method static booleanToInt(Z)I .registers 2 if-eqz p0, :cond_4 const/4 v0, 0x1 :goto_3 return v0 :cond_4 const/4 v0, 0x0 goto :goto_3 .end method ## CHECK-START: long SmaliTests.booleanToLong(boolean) builder (after) ## CHECK-DAG: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Equal [<>,<>] ## CHECK-DAG: If [<>] ## CHECK-DAG: <> Phi [<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: long SmaliTests.booleanToLong(boolean) select_generator (after) ## CHECK-DAG: <> ParameterValue ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> Select [<>,<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: long SmaliTests.booleanToLong(boolean) instruction_simplifier$after_bce (after) ## CHECK-DAG: <> ParameterValue ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] .method public static booleanToLong(Z)J .registers 3 .param p0, "b" # Z .prologue # return b ? 1 : 0; if-eqz p0, :b_is_zero # :b_is_one const/4 v0, 0x1 :l_return int-to-long v0, v0 return-wide v0 :b_is_zero const/4 v0, 0x0 goto :l_return .end method ## CHECK-START: int SmaliTests.longToIntOfBoolean() builder (after) ## CHECK-DAG: <> StaticFieldGet ## CHECK-DAG: <> InvokeStaticOrDirect [<>{{(,[ij]\d+)?}}] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: int SmaliTests.longToIntOfBoolean() inliner (after) ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> StaticFieldGet ## CHECK-DAG: If [<>] ## CHECK-DAG: <> Phi [<>,<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: <> TypeConversion [<>] ## CHECK-DAG: Return [<>] ## CHECK-START: int SmaliTests.longToIntOfBoolean() select_generator (after) ## CHECK-DAG: <> IntConstant 0 ## CHECK-DAG: <> IntConstant 1 ## CHECK-DAG: <> StaticFieldGet ## CHECK-DAG: <> Select [<>,<>,<>] ## CHECK-DAG: Return [<>] ## CHECK-START: int SmaliTests.longToIntOfBoolean() instruction_simplifier$after_bce (after) ## CHECK-DAG: <> StaticFieldGet ## CHECK-DAG: Return [<>] .method public static longToIntOfBoolean()I .registers 3 .prologue # long l = booleanToLong(booleanField); sget-boolean v2, LSmaliTests;->booleanField:Z invoke-static {v2}, LSmaliTests;->booleanToLong(Z)J move-result-wide v0 # return (int) l; long-to-int v2, v0 return v2 .end method