summaryrefslogtreecommitdiff
path: root/compiler/optimizing/optimization.h
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2017-11-15 15:17:53 -0800
committerAart Bik <ajcbik@google.com>2017-11-20 10:38:26 -0800
commit2ca10eb3f47ef3c2535c137853f7a63d10bb908b (patch)
tree3684d1d5ef4791795b64620e97f952896c5a2011 /compiler/optimizing/optimization.h
parent02f41015a0933f146b886c62bb5b02c322ddf882 (diff)
Refactored optimization passes setup.
Rationale: Refactors the way we set up optimization passes in the compiler into a more centralized approach. The refactoring also found some "holes" in the existing mechanism (missing string lookup in the debugging mechanism, or inablity to set alternative name for optimizations that may repeat). Bug: 64538565 Test: test-art-host test-art-target Change-Id: Ie5e0b70f67ac5acc706db91f64612dff0e561f83
Diffstat (limited to 'compiler/optimizing/optimization.h')
-rw-r--r--compiler/optimizing/optimization.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/compiler/optimizing/optimization.h b/compiler/optimizing/optimization.h
index ce41a2e512..c170f155fa 100644
--- a/compiler/optimizing/optimization.h
+++ b/compiler/optimizing/optimization.h
@@ -23,6 +23,10 @@
namespace art {
+class CodeGenerator;
+class CompilerDriver;
+class DexCompilationUnit;
+
/**
* Abstraction to implement an optimization pass.
*/
@@ -58,6 +62,81 @@ class HOptimization : public ArenaObject<kArenaAllocOptimization> {
DISALLOW_COPY_AND_ASSIGN(HOptimization);
};
+// Optimization passes that can be constructed by the helper method below. An enum
+// field is preferred over a string lookup at places where performance matters.
+// TODO: generate this table and lookup methods below automatically?
+enum class OptimizationPass {
+ kBoundsCheckElimination,
+ kCHAGuardOptimization,
+ kCodeSinking,
+ kConstantFolding,
+ kConstructorFenceRedundancyElimination,
+ kDeadCodeElimination,
+ kGlobalValueNumbering,
+ kInductionVarAnalysis,
+ kInliner,
+ kInstructionSimplifier,
+ kIntrinsicsRecognizer,
+ kInvariantCodeMotion,
+ kLoadStoreAnalysis,
+ kLoadStoreElimination,
+ kLoopOptimization,
+ kScheduling,
+ kSelectGenerator,
+ kSharpening,
+ kSideEffectsAnalysis,
+#ifdef ART_ENABLE_CODEGEN_arm
+ kInstructionSimplifierArm,
+#endif
+#ifdef ART_ENABLE_CODEGEN_arm64
+ kInstructionSimplifierArm64,
+#endif
+#ifdef ART_ENABLE_CODEGEN_mips
+ kPcRelativeFixupsMips,
+ kInstructionSimplifierMips,
+#endif
+#ifdef ART_ENABLE_CODEGEN_x86
+ kPcRelativeFixupsX86,
+#endif
+#if defined(ART_ENABLE_CODEGEN_x86) || defined(ART_ENABLE_CODEGEN_x86_64)
+ kX86MemoryOperandGeneration,
+#endif
+};
+
+// Lookup name of optimization pass.
+const char* OptimizationPassName(OptimizationPass pass);
+
+// Lookup optimization pass by name.
+OptimizationPass OptimizationPassByName(const std::string& name);
+
+// Optimization definition consisting of an optimization pass
+// and an optional alternative name (nullptr denotes default).
+typedef std::pair<OptimizationPass, const char*> OptimizationDef;
+
+// Helper method for optimization definition array entries.
+inline OptimizationDef OptDef(OptimizationPass pass, const char* name = nullptr) {
+ return std::make_pair(pass, name);
+}
+
+// Helper method to construct series of optimization passes.
+// The array should consist of the requested optimizations
+// and optional alternative names for repeated passes.
+// Example:
+// { OptPass(kConstantFolding),
+// OptPass(Inliner),
+// OptPass(kConstantFolding, "constant_folding$after_inlining")
+// }
+ArenaVector<HOptimization*> ConstructOptimizations(
+ const OptimizationDef definitions[],
+ size_t length,
+ ArenaAllocator* allocator,
+ HGraph* graph,
+ OptimizingCompilerStats* stats,
+ CodeGenerator* codegen,
+ CompilerDriver* driver,
+ const DexCompilationUnit& dex_compilation_unit,
+ VariableSizedHandleScope* handles);
+
} // namespace art
#endif // ART_COMPILER_OPTIMIZING_OPTIMIZATION_H_