1 /* 2 * Copyright (C) 2009 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 /* Forward-declare the portable versions due to circular dependency */ 18 static bool genArithOpFloatPortable(CompilationUnit *cUnit, MIR *mir, 19 RegLocation rlDest, RegLocation rlSrc1, 20 RegLocation rlSrc2); 21 22 static bool genArithOpDoublePortable(CompilationUnit *cUnit, MIR *mir, 23 RegLocation rlDest, RegLocation rlSrc1, 24 RegLocation rlSrc2); 25 26 static bool genConversionPortable(CompilationUnit *cUnit, MIR *mir); 27 28 static bool handleExecuteInlineC(CompilationUnit *cUnit, MIR *mir); 29 30 static bool genConversion(CompilationUnit *cUnit, MIR *mir) 31 { 32 return genConversionPortable(cUnit, mir); 33 } 34 35 static bool genArithOpFloat(CompilationUnit *cUnit, MIR *mir, 36 RegLocation rlDest, RegLocation rlSrc1, 37 RegLocation rlSrc2) 38 { 39 return genArithOpFloatPortable(cUnit, mir, rlDest, rlSrc1, rlSrc2); 40 } 41 42 static bool genArithOpDouble(CompilationUnit *cUnit, MIR *mir, 43 RegLocation rlDest, RegLocation rlSrc1, 44 RegLocation rlSrc2) 45 { 46 return genArithOpDoublePortable(cUnit, mir, rlDest, rlSrc1, rlSrc2); 47 } 48 49 static bool genInlineSqrt(CompilationUnit *cUnit, MIR *mir) 50 { 51 return handleExecuteInlineC(cUnit, mir); 52 } 53 54 static bool genCmpFP(CompilationUnit *cUnit, MIR *mir, RegLocation rlDest, 55 RegLocation rlSrc1, RegLocation rlSrc2) 56 { 57 RegLocation rlResult = LOC_C_RETURN; 58 /* 59 * Don't attempt to optimize register usage since these opcodes call out to 60 * the handlers. 61 */ 62 switch (mir->dalvikInsn.opcode) { 63 case OP_CMPL_FLOAT: 64 loadValueDirectFixed(cUnit, rlSrc1, r0); 65 loadValueDirectFixed(cUnit, rlSrc2, r1); 66 genDispatchToHandler(cUnit, TEMPLATE_CMPL_FLOAT); 67 storeValue(cUnit, rlDest, rlResult); 68 break; 69 case OP_CMPG_FLOAT: 70 loadValueDirectFixed(cUnit, rlSrc1, r0); 71 loadValueDirectFixed(cUnit, rlSrc2, r1); 72 genDispatchToHandler(cUnit, TEMPLATE_CMPG_FLOAT); 73 storeValue(cUnit, rlDest, rlResult); 74 break; 75 case OP_CMPL_DOUBLE: 76 loadValueDirectWideFixed(cUnit, rlSrc1, r0, r1); 77 loadValueDirectWideFixed(cUnit, rlSrc2, r2, r3); 78 genDispatchToHandler(cUnit, TEMPLATE_CMPL_DOUBLE); 79 storeValue(cUnit, rlDest, rlResult); 80 break; 81 case OP_CMPG_DOUBLE: 82 loadValueDirectWideFixed(cUnit, rlSrc1, r0, r1); 83 loadValueDirectWideFixed(cUnit, rlSrc2, r2, r3); 84 genDispatchToHandler(cUnit, TEMPLATE_CMPG_DOUBLE); 85 storeValue(cUnit, rlDest, rlResult); 86 break; 87 default: 88 return true; 89 } 90 return false; 91 } 92