Codegen.h revision 88dc28740f628a8d0d8fe05af0e11443f8793aa1
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/*
18 * This file contains register alloction support and is intended to be
19 * included by:
20 *
21 *        Codegen-$(TARGET_ARCH_VARIANT).c
22 *
23 */
24
25#include "compiler/CompilerIR.h"
26
27/*
28 * loadConstant() sometimes needs to add a small imm to a pre-existing constant
29 */
30static ArmLIR *opRegImm(CompilationUnit *cUnit, OpKind op, int rDestSrc1,
31                        int value);
32static ArmLIR *opRegReg(CompilationUnit *cUnit, OpKind op, int rDestSrc1,
33                        int rSrc2);
34
35/* Forward decalraton the portable versions due to circular dependency */
36static bool genArithOpFloatPortable(CompilationUnit *cUnit, MIR *mir,
37                                    RegLocation rlDest, RegLocation rlSrc1,
38                                    RegLocation rlSrc2);
39
40static bool genArithOpDoublePortable(CompilationUnit *cUnit, MIR *mir,
41                                     RegLocation rlDest, RegLocation rlSrc1,
42                                     RegLocation rlSrc2);
43
44static bool genConversionPortable(CompilationUnit *cUnit, MIR *mir);
45
46static void genMonitorPortable(CompilationUnit *cUnit, MIR *mir);
47
48#if defined(WITH_SELF_VERIFICATION)
49/* Self Verification memory instruction decoder */
50void dvmSelfVerificationMemOpDecode(int lr, int* sp);
51#endif
52
53/*
54 * Architecture-dependent register allocation routines implemented in
55 * Thumb[2]/Ralloc.c
56 */
57extern int dvmCompilerAllocTypedTempPair(CompilationUnit *cUnit,
58                                         bool fpHint, int regClass);
59
60extern int dvmCompilerAllocTypedTemp(CompilationUnit *cUnit, bool fpHint,
61                                     int regClass);
62
63extern ArmLIR* dvmCompilerRegCopyNoInsert(CompilationUnit *cUnit, int rDest,
64                                          int rSrc);
65
66extern ArmLIR* dvmCompilerRegCopy(CompilationUnit *cUnit, int rDest, int rSrc);
67
68extern void dvmCompilerRegCopyWide(CompilationUnit *cUnit, int destLo,
69                                   int destHi, int srcLo, int srcHi);
70
71extern void dvmCompilerFlushRegImpl(CompilationUnit *cUnit, int rBase,
72                                    int displacement, int rSrc, OpSize size);
73
74extern void dvmCompilerFlushRegWideImpl(CompilationUnit *cUnit, int rBase,
75                                        int displacement, int rSrcLo,
76                                        int rSrcHi);
77