From 86dbb9a12119273039ce272b41c809fa548b37b6 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 4 Jun 2014 11:12:39 +0100 Subject: Final CL to enable register allocation on x86. This CL implements: 1) Resolution after allocation: connecting the locations allocated to an interval within a block and between blocks. 2) Handling of fixed registers: some instructions require inputs/output to be at a specific location, and the allocator needs to deal with them in a special way. 3) ParallelMoveResolver::EmitNativeCode for x86. Change-Id: I0da6bd7eb66877987148b87c3be6a983b4e3f858 --- compiler/optimizing/optimizing_compiler.cc | 46 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 3dc0928d6d..ccacbef401 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -85,6 +85,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite // For testing purposes, we put a special marker on method names that should be compiled // with this compiler. This makes sure we're not regressing. bool shouldCompile = dex_compilation_unit.GetSymbol().find("00024opt_00024") != std::string::npos; + bool shouldOptimize = + dex_compilation_unit.GetSymbol().find("00024reg_00024") != std::string::npos; ArenaPool pool; ArenaAllocator arena(&pool); @@ -116,7 +118,36 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite visualizer.DumpGraph("builder"); CodeVectorAllocator allocator; - codegen->Compile(&allocator); + + if (RegisterAllocator::CanAllocateRegistersFor(*graph, instruction_set)) { + graph->BuildDominatorTree(); + graph->TransformToSSA(); + visualizer.DumpGraph("ssa"); + + graph->FindNaturalLoops(); + SsaLivenessAnalysis liveness(*graph, codegen); + liveness.Analyze(); + visualizer.DumpGraph(kLivenessPassName); + + RegisterAllocator register_allocator(graph->GetArena(), codegen, liveness); + register_allocator.AllocateRegisters(); + + visualizer.DumpGraph(kRegisterAllocatorPassName); + codegen->CompileOptimized(&allocator); + } else if (shouldOptimize && RegisterAllocator::Supports(instruction_set)) { + LOG(FATAL) << "Could not allocate registers in optimizing compiler"; + } else { + codegen->CompileBaseline(&allocator); + + // Run these phases to get some test coverage. + graph->BuildDominatorTree(); + graph->TransformToSSA(); + visualizer.DumpGraph("ssa"); + graph->FindNaturalLoops(); + SsaLivenessAnalysis liveness(*graph, codegen); + liveness.Analyze(); + visualizer.DumpGraph(kLivenessPassName); + } std::vector mapping_table; codegen->BuildMappingTable(&mapping_table); @@ -125,19 +156,6 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite std::vector gc_map; codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit); - // Run these phases to get some test coverage. - graph->BuildDominatorTree(); - graph->TransformToSSA(); - visualizer.DumpGraph("ssa"); - - graph->FindNaturalLoops(); - SsaLivenessAnalysis liveness(*graph, codegen); - liveness.Analyze(); - visualizer.DumpGraph("liveness"); - - RegisterAllocator(graph->GetArena(), *codegen).AllocateRegisters(liveness); - visualizer.DumpGraph("register"); - return new CompiledMethod(GetCompilerDriver(), instruction_set, allocator.GetMemory(), -- cgit v1.2.3-59-g8ed1b