blob: 28a689fb4bca4a56de2eb9a372aa57f5316ad847 [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 Carlstrom3320cf42011-10-04 14:58:28 -0700102CompiledMethod* oatCompileMethod(const Compiler& compiler,
103 const Method* method,
104 OatInstructionSetType);
buzbee67bf8852011-08-17 17:51:35 -0700105void oatDumpStats(void);
106void oatScanAllClassPointers(void (*callback)(void* ptr));
107void oatInitializeSSAConversion(struct CompilationUnit* cUnit);
108int oatConvertSSARegToDalvik(const struct CompilationUnit* cUnit, int ssaReg);
109bool oatFindLocalLiveIn(struct CompilationUnit* cUnit,
110 struct BasicBlock* bb);
111bool oatDoSSAConversion(struct CompilationUnit* cUnit,
112 struct BasicBlock* bb);
113bool oatDoConstantPropagation(struct CompilationUnit* cUnit,
114 struct BasicBlock* bb);
115bool oatFindInductionVariables(struct CompilationUnit* cUnit,
116 struct BasicBlock* bb);
117/* Clear the visited flag for each BB */
118bool oatClearVisitedFlag(struct CompilationUnit* cUnit,
119 struct BasicBlock* bb);
120char *oatGetDalvikDisassembly(const DecodedInstruction* insn,
121 const char* note);
122char *oatFullDisassembler(const struct CompilationUnit* cUnit,
123 const struct MIR* mir);
124char *oatGetSSAString(struct CompilationUnit* cUnit,
125 struct SSARepresentation* ssaRep);
126void oatDataFlowAnalysisDispatcher(struct CompilationUnit* cUnit,
127 bool (*func)(struct CompilationUnit* , struct BasicBlock*),
128 DataFlowAnalysisMode dfaMode,
129 bool isIterative);
130void oatMethodSSATransformation(struct CompilationUnit* cUnit);
131u8 oatGetRegResourceMask(int reg);
132void oatDumpCFG(struct CompilationUnit* cUnit, const char* dirPrefix);
133void oatProcessSwitchTables(CompilationUnit* cUnit);
134
135#endif // ART_SRC_COMPILER_COMPILER_H_