buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 23 | typedef enum OatInstructionSetType { |
| 24 | DALVIK_OAT_NONE = 0, |
| 25 | DALVIK_OAT_ARM, |
| 26 | DALVIK_OAT_THUMB2, |
| 27 | } OatInstructionSetType; |
| 28 | |
| 29 | typedef 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 */ |
| 50 | typedef 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 | |
| 58 | struct CompilationUnit; |
| 59 | struct BasicBlock; |
| 60 | struct SSARepresentation; |
| 61 | struct GrowableList; |
| 62 | struct MIR; |
| 63 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 64 | void oatInit(const Compiler& compiler); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 65 | bool oatArchInit(void); |
| 66 | void oatArchDump(void); |
| 67 | bool oatStartup(void); |
| 68 | void oatShutdown(void); |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 69 | bool oatCompileMethod(const Compiler& compiler, Method* method, OatInstructionSetType); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 70 | void oatDumpStats(void); |
| 71 | void oatScanAllClassPointers(void (*callback)(void* ptr)); |
| 72 | void oatInitializeSSAConversion(struct CompilationUnit* cUnit); |
| 73 | int oatConvertSSARegToDalvik(const struct CompilationUnit* cUnit, int ssaReg); |
| 74 | bool oatFindLocalLiveIn(struct CompilationUnit* cUnit, |
| 75 | struct BasicBlock* bb); |
| 76 | bool oatDoSSAConversion(struct CompilationUnit* cUnit, |
| 77 | struct BasicBlock* bb); |
| 78 | bool oatDoConstantPropagation(struct CompilationUnit* cUnit, |
| 79 | struct BasicBlock* bb); |
| 80 | bool oatFindInductionVariables(struct CompilationUnit* cUnit, |
| 81 | struct BasicBlock* bb); |
| 82 | /* Clear the visited flag for each BB */ |
| 83 | bool oatClearVisitedFlag(struct CompilationUnit* cUnit, |
| 84 | struct BasicBlock* bb); |
| 85 | char *oatGetDalvikDisassembly(const DecodedInstruction* insn, |
| 86 | const char* note); |
| 87 | char *oatFullDisassembler(const struct CompilationUnit* cUnit, |
| 88 | const struct MIR* mir); |
| 89 | char *oatGetSSAString(struct CompilationUnit* cUnit, |
| 90 | struct SSARepresentation* ssaRep); |
| 91 | void oatDataFlowAnalysisDispatcher(struct CompilationUnit* cUnit, |
| 92 | bool (*func)(struct CompilationUnit* , struct BasicBlock*), |
| 93 | DataFlowAnalysisMode dfaMode, |
| 94 | bool isIterative); |
| 95 | void oatMethodSSATransformation(struct CompilationUnit* cUnit); |
| 96 | u8 oatGetRegResourceMask(int reg); |
| 97 | void oatDumpCFG(struct CompilationUnit* cUnit, const char* dirPrefix); |
| 98 | void oatProcessSwitchTables(CompilationUnit* cUnit); |
| 99 | |
| 100 | #endif // ART_SRC_COMPILER_COMPILER_H_ |