blob: ba97aac6e76560560b541ab8001725c632e05efd [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
29typedef enum OatMethodAttributes {
30 kIsCallee = 0, /* Code is part of a callee (invoked by a hot trace) */
31 kIsHot, /* Code is part of a hot trace */
32 kIsLeaf, /* Method is leaf */
33 kIsEmpty, /* Method is empty */
34 kIsThrowFree, /* Method doesn't throw */
35 kIsGetter, /* Method fits the getter pattern */
36 kIsSetter, /* Method fits the setter pattern */
37 kCannotCompile, /* Method cannot be compiled */
38} OatMethodAttributes;
39
40#define METHOD_IS_CALLEE (1 << kIsCallee)
41#define METHOD_IS_HOT (1 << kIsHot)
42#define METHOD_IS_LEAF (1 << kIsLeaf)
43#define METHOD_IS_EMPTY (1 << kIsEmpty)
44#define METHOD_IS_THROW_FREE (1 << kIsThrowFree)
45#define METHOD_IS_GETTER (1 << kIsGetter)
46#define METHOD_IS_SETTER (1 << kIsSetter)
47#define METHOD_CANNOT_COMPILE (1 << kCannotCompile)
48
49/* Customized node traversal orders for different needs */
50typedef enum DataFlowAnalysisMode {
51 kAllNodes = 0, // All nodes
52 kReachableNodes, // All reachable nodes
53 kPreOrderDFSTraversal, // Depth-First-Search / Pre-Order
54 kPostOrderDFSTraversal, // Depth-First-Search / Post-Order
55 kPostOrderDOMTraversal, // Dominator tree / Post-Order
56} DataFlowAnalysisMode;
57
58struct CompilationUnit;
59struct BasicBlock;
60struct SSARepresentation;
61struct GrowableList;
62struct MIR;
63
Brian Carlstrom16192862011-09-12 17:50:06 -070064void oatInit(const Compiler& compiler);
buzbee67bf8852011-08-17 17:51:35 -070065bool oatArchInit(void);
66void oatArchDump(void);
67bool oatStartup(void);
68void oatShutdown(void);
Brian Carlstrom16192862011-09-12 17:50:06 -070069bool oatCompileMethod(const Compiler& compiler, Method* method, OatInstructionSetType);
buzbee67bf8852011-08-17 17:51:35 -070070void oatDumpStats(void);
71void oatScanAllClassPointers(void (*callback)(void* ptr));
72void oatInitializeSSAConversion(struct CompilationUnit* cUnit);
73int oatConvertSSARegToDalvik(const struct CompilationUnit* cUnit, int ssaReg);
74bool oatFindLocalLiveIn(struct CompilationUnit* cUnit,
75 struct BasicBlock* bb);
76bool oatDoSSAConversion(struct CompilationUnit* cUnit,
77 struct BasicBlock* bb);
78bool oatDoConstantPropagation(struct CompilationUnit* cUnit,
79 struct BasicBlock* bb);
80bool oatFindInductionVariables(struct CompilationUnit* cUnit,
81 struct BasicBlock* bb);
82/* Clear the visited flag for each BB */
83bool oatClearVisitedFlag(struct CompilationUnit* cUnit,
84 struct BasicBlock* bb);
85char *oatGetDalvikDisassembly(const DecodedInstruction* insn,
86 const char* note);
87char *oatFullDisassembler(const struct CompilationUnit* cUnit,
88 const struct MIR* mir);
89char *oatGetSSAString(struct CompilationUnit* cUnit,
90 struct SSARepresentation* ssaRep);
91void oatDataFlowAnalysisDispatcher(struct CompilationUnit* cUnit,
92 bool (*func)(struct CompilationUnit* , struct BasicBlock*),
93 DataFlowAnalysisMode dfaMode,
94 bool isIterative);
95void oatMethodSSATransformation(struct CompilationUnit* cUnit);
96u8 oatGetRegResourceMask(int reg);
97void oatDumpCFG(struct CompilationUnit* cUnit, const char* dirPrefix);
98void oatProcessSwitchTables(CompilationUnit* cUnit);
99
100#endif // ART_SRC_COMPILER_COMPILER_H_