blob: f9e2478e47c3c242b1063a22135a2c67ef5fae63 [file] [log] [blame]
buzbee67bf8852011-08-17 17:51:35 -07001/*
2 * Copyright (C) 2011 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#ifndef ART_SRC_COMPILER_COMPILER_H_
18#define ART_SRC_COMPILER_COMPILER_H_
19
20#define COMPILER_TRACED(X)
21#define COMPILER_TRACEE(X)
22
23typedef enum OatInstructionSetType {
24 DALVIK_OAT_NONE = 0,
25 DALVIK_OAT_ARM,
26 DALVIK_OAT_THUMB2,
27} OatInstructionSetType;
28
buzbeece302932011-10-04 14:32:18 -070029/* Supress optimization if corresponding bit set */
30enum optControlVector {
31 kLoadStoreElimination = 0,
32 kLoadHoisting,
33 kSuppressLoads,
34 kNullCheckElimination,
35 kPromoteRegs,
36 kTrackLiveTemps,
37};
38
39extern uint32_t compilerOptimizerDisableFlags;
40
41/* Force code generation paths for testing */
42enum debugControlVector {
43 kDebugDisplayMissingTargets,
44 kDebugVerbose,
45 kDebugDumpCFG,
46 kDebugSlowFieldPath,
47 kDebugSlowInvokePath,
48 kDebugSlowStringPath,
49 kDebugSlowTypePath,
50 kDebugSlowestFieldPath,
51 kDebugSlowestStringPath,
52};
53
54extern uint32_t compilerDebugFlags;
55
56/* If non-empty, apply optimizer/debug flags only to matching methods */
57extern std::string compilerMethodMatch;
58
59/* Flips sense of compilerMethodMatch - apply flags if doesn't match */
60extern bool compilerFlipMatch;
61
buzbee67bf8852011-08-17 17:51:35 -070062typedef enum OatMethodAttributes {
63 kIsCallee = 0, /* Code is part of a callee (invoked by a hot trace) */
64 kIsHot, /* Code is part of a hot trace */
65 kIsLeaf, /* Method is leaf */
66 kIsEmpty, /* Method is empty */
67 kIsThrowFree, /* Method doesn't throw */
68 kIsGetter, /* Method fits the getter pattern */
69 kIsSetter, /* Method fits the setter pattern */
70 kCannotCompile, /* Method cannot be compiled */
71} OatMethodAttributes;
72
73#define METHOD_IS_CALLEE (1 << kIsCallee)
74#define METHOD_IS_HOT (1 << kIsHot)
75#define METHOD_IS_LEAF (1 << kIsLeaf)
76#define METHOD_IS_EMPTY (1 << kIsEmpty)
77#define METHOD_IS_THROW_FREE (1 << kIsThrowFree)
78#define METHOD_IS_GETTER (1 << kIsGetter)
79#define METHOD_IS_SETTER (1 << kIsSetter)
80#define METHOD_CANNOT_COMPILE (1 << kCannotCompile)
81
82/* Customized node traversal orders for different needs */
83typedef enum DataFlowAnalysisMode {
84 kAllNodes = 0, // All nodes
85 kReachableNodes, // All reachable nodes
86 kPreOrderDFSTraversal, // Depth-First-Search / Pre-Order
87 kPostOrderDFSTraversal, // Depth-First-Search / Post-Order
88 kPostOrderDOMTraversal, // Dominator tree / Post-Order
89} DataFlowAnalysisMode;
90
91struct CompilationUnit;
92struct BasicBlock;
93struct SSARepresentation;
94struct GrowableList;
95struct MIR;
96
Brian Carlstrom16192862011-09-12 17:50:06 -070097void oatInit(const Compiler& compiler);
buzbee67bf8852011-08-17 17:51:35 -070098bool oatArchInit(void);
99void oatArchDump(void);
100bool oatStartup(void);
101void oatShutdown(void);
Brian Carlstrom16192862011-09-12 17:50:06 -0700102bool oatCompileMethod(const Compiler& compiler, Method* method, OatInstructionSetType);
buzbee67bf8852011-08-17 17:51:35 -0700103void oatDumpStats(void);
104void oatScanAllClassPointers(void (*callback)(void* ptr));
105void oatInitializeSSAConversion(struct CompilationUnit* cUnit);
106int oatConvertSSARegToDalvik(const struct CompilationUnit* cUnit, int ssaReg);
107bool oatFindLocalLiveIn(struct CompilationUnit* cUnit,
108 struct BasicBlock* bb);
109bool oatDoSSAConversion(struct CompilationUnit* cUnit,
110 struct BasicBlock* bb);
111bool oatDoConstantPropagation(struct CompilationUnit* cUnit,
112 struct BasicBlock* bb);
113bool oatFindInductionVariables(struct CompilationUnit* cUnit,
114 struct BasicBlock* bb);
115/* Clear the visited flag for each BB */
116bool oatClearVisitedFlag(struct CompilationUnit* cUnit,
117 struct BasicBlock* bb);
118char *oatGetDalvikDisassembly(const DecodedInstruction* insn,
119 const char* note);
120char *oatFullDisassembler(const struct CompilationUnit* cUnit,
121 const struct MIR* mir);
122char *oatGetSSAString(struct CompilationUnit* cUnit,
123 struct SSARepresentation* ssaRep);
124void oatDataFlowAnalysisDispatcher(struct CompilationUnit* cUnit,
125 bool (*func)(struct CompilationUnit* , struct BasicBlock*),
126 DataFlowAnalysisMode dfaMode,
127 bool isIterative);
128void oatMethodSSATransformation(struct CompilationUnit* cUnit);
129u8 oatGetRegResourceMask(int reg);
130void oatDumpCFG(struct CompilationUnit* cUnit, const char* dirPrefix);
131void oatProcessSwitchTables(CompilationUnit* cUnit);
132
133#endif // ART_SRC_COMPILER_COMPILER_H_