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