OSDN Git Service

Restructure the codegen to make architectural depedency explicit.
[android-x86/dalvik.git] / vm / compiler / codegen / arm / FP / ThumbPortableFP.c
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 decalraton 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 genConversion(CompilationUnit *cUnit, MIR *mir)
29 {
30     return genConversionPortable(cUnit, mir);
31 }
32
33 static bool genArithOpFloat(CompilationUnit *cUnit, MIR *mir,
34                             RegLocation rlDest, RegLocation rlSrc1,
35                             RegLocation rlSrc2)
36 {
37     return genArithOpFloatPortable(cUnit, mir, rlDest, rlSrc1, rlSrc2);
38 }
39
40 static bool genArithOpDouble(CompilationUnit *cUnit, MIR *mir,
41                              RegLocation rlDest, RegLocation rlSrc1,
42                              RegLocation rlSrc2)
43 {
44     return genArithOpDoublePortable(cUnit, mir, rlDest, rlSrc1, rlSrc2);
45 }
46
47 static bool genInlineSqrt(CompilationUnit *cUnit, MIR *mir)
48 {
49     return false;   /* punt to C handler */
50 }
51
52 static bool genCmpFP(CompilationUnit *cUnit, MIR *mir, RegLocation rlDest,
53                      RegLocation rlSrc1, RegLocation rlSrc2)
54 {
55     RegLocation rlResult = LOC_C_RETURN;
56     /*
57      * Don't attempt to optimize register usage since these opcodes call out to
58      * the handlers.
59      */
60     switch (mir->dalvikInsn.opCode) {
61         case OP_CMPL_FLOAT:
62             loadValueDirectFixed(cUnit, rlSrc1, r0);
63             loadValueDirectFixed(cUnit, rlSrc2, r1);
64             genDispatchToHandler(cUnit, TEMPLATE_CMPL_FLOAT);
65             storeValue(cUnit, rlDest, rlResult);
66             break;
67         case OP_CMPG_FLOAT:
68             loadValueDirectFixed(cUnit, rlSrc1, r0);
69             loadValueDirectFixed(cUnit, rlSrc2, r1);
70             genDispatchToHandler(cUnit, TEMPLATE_CMPG_FLOAT);
71             storeValue(cUnit, rlDest, rlResult);
72             break;
73         case OP_CMPL_DOUBLE:
74             loadValueDirectWideFixed(cUnit, rlSrc1, r0, r1);
75             loadValueDirectWideFixed(cUnit, rlSrc2, r2, r3);
76             genDispatchToHandler(cUnit, TEMPLATE_CMPL_DOUBLE);
77             storeValue(cUnit, rlDest, rlResult);
78             break;
79         case OP_CMPG_DOUBLE:
80             loadValueDirectWideFixed(cUnit, rlSrc1, r0, r1);
81             loadValueDirectWideFixed(cUnit, rlSrc2, r2, r3);
82             genDispatchToHandler(cUnit, TEMPLATE_CMPG_DOUBLE);
83             storeValue(cUnit, rlDest, rlResult);
84             break;
85         default:
86             return true;
87     }
88     return false;
89 }