blob: 0931df3d0958a329cd85b4c7023a97916e62f218 [file] [log] [blame]
Ben Chenge9695e52009-06-16 16:11:47 -07001/*
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
Ben Chenge9695e52009-06-16 16:11:47 -070017#ifndef _DALVIK_VM_COMPILER_OPTIMIZATION_H
18#define _DALVIK_VM_COMPILER_OPTIMIZATION_H
19
Ben Cheng4238ec22009-08-24 16:32:22 -070020#include "Dalvik.h"
21
Ben Chengdcf3e5d2009-09-11 13:42:05 -070022/*
23 * If the corresponding bit is set in gDvmJit.disableOpt, the selected
24 * optimization will be suppressed.
25 */
26typedef enum optControlVector {
27 kLoadStoreElimination = 0,
28 kLoadHoisting,
29} optControlVector;
30
Ben Chenge9695e52009-06-16 16:11:47 -070031/* Forward declarations */
32struct CompilationUnit;
33struct LIR;
34
35/*
36 * Data structure tracking the mapping between a Dalvik register (pair) and a
37 * native register (pair). The idea is to reuse the previously loaded value
38 * if possible, otherwise to keep the value in a native register as long as
39 * possible.
40 */
41typedef struct RegisterScoreboard {
42 BitVector *nullCheckedRegs; // Track which registers have been null-checked
43 int liveDalvikReg; // Track which Dalvik register is live
44 int nativeReg; // And the mapped native register
45 int nativeRegHi; // And the mapped native register
46 bool isWide; // Whether a pair of registers are alive
47} RegisterScoreboard;
48
49void dvmCompilerApplyLocalOptimizations(struct CompilationUnit *cUnit,
50 struct LIR *head,
51 struct LIR *tail);
52
53void dvmCompilerApplyGlobalOptimizations(struct CompilationUnit *cUnit);
54
55#endif /* _DALVIK_VM_COMPILER_OPTIMIZATION_H */