Add new files and data structures for the new register allocator.

This CL adds new files to hold the new register allocator and
adds a parallel-move instructions that will be used to insert
moves for register constraints, spills and phi-resolution.

No new functionality added yet.
Review URL: https://chromiumcodereview.appspot.com//10635020

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9027 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
fschneider@google.com 2012-06-22 10:59:06 +00:00
parent d4c4113bc8
commit 63d4ad7d5f
8 changed files with 118 additions and 5 deletions

View file

@ -13,6 +13,7 @@
#include "vm/disassembler.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
#include "vm/flow_graph_allocator.h"
#include "vm/flow_graph_builder.h"
#include "vm/flow_graph_compiler.h"
#include "vm/flow_graph_optimizer.h"
@ -34,6 +35,7 @@ DEFINE_FLAG(int, deoptimization_counter_threshold, 5,
" certain optimizations");
DEFINE_FLAG(bool, use_new_compiler, true, "Use the new compiler backend.");
DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from new compiler.");
DECLARE_FLAG(bool, use_ssa);
// Compile a function. Should call only if the function has not been compiled.
@ -193,6 +195,15 @@ static bool CompileWithNewCompiler(
if (optimized) {
FlowGraphOptimizer optimizer(block_order);
optimizer.ApplyICData();
if (FLAG_use_ssa) {
// Perform register allocation on the SSA graph.
FlowGraphAllocator allocator(block_order);
allocator.ResolveConstraints();
// Temporary bailout until we support code generation from SSA form.
graph_builder.Bailout("No SSA code generation support.");
}
}
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/flow_graph_allocator.h"
#include "vm/intermediate_language.h"
namespace dart {
void FlowGraphAllocator::ResolveConstraints() {
// TODO(fschneider): Resolve register constraints.
}
} // namespace dart

View file

@ -0,0 +1,28 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_FLOW_GRAPH_ALLOCATOR_H_
#define VM_FLOW_GRAPH_ALLOCATOR_H_
#include "vm/growable_array.h"
#include "vm/intermediate_language.h"
namespace dart {
class FlowGraphAllocator : public ValueObject {
public:
explicit FlowGraphAllocator(const GrowableArray<BlockEntryInstr*>& blocks)
: blocks_(blocks) { }
void ResolveConstraints();
private:
const GrowableArray<BlockEntryInstr*>& blocks_;
DISALLOW_COPY_AND_ASSIGN(FlowGraphAllocator);
};
} // namespace dart
#endif // VM_FLOW_GRAPH_ALLOCATOR_H_

View file

@ -2375,10 +2375,6 @@ void FlowGraphBuilder::BuildGraph(bool for_optimized) {
printer.PrintFunction();
}
}
if (for_optimized && FLAG_use_ssa) {
Bailout("No SSA code generation support.");
}
}

View file

@ -412,6 +412,11 @@ void BranchInstr::PrintTo(BufferFormatter* f) const {
}
void ParallelMoveInstr::PrintTo(BufferFormatter* f) const {
UNIMPLEMENTED();
}
void FlowGraphVisualizer::Print(const char* format, ...) {
char str[120];
BufferFormatter f(str, sizeof(str));
@ -639,4 +644,10 @@ void BranchInstr::PrintToVisualizer(BufferFormatter* f) const {
}
void ParallelMoveInstr::PrintToVisualizer(BufferFormatter* f) const {
UNIMPLEMENTED();
}
} // namespace dart

View file

@ -170,6 +170,23 @@ void BranchInstr::SetInputAt(intptr_t i, Value* value) {
}
intptr_t ParallelMoveInstr::InputCount() const {
UNREACHABLE();
return 0;
}
Value* ParallelMoveInstr::InputAt(intptr_t i) const {
UNREACHABLE();
return NULL;
}
void ParallelMoveInstr::SetInputAt(intptr_t i, Value* value) {
UNREACHABLE();
}
intptr_t ReThrowInstr::InputCount() const {
return 2;
}

View file

@ -9,6 +9,7 @@
#include "vm/ast.h"
#include "vm/growable_array.h"
#include "vm/handles_impl.h"
#include "vm/locations.h"
#include "vm/object.h"
namespace dart {
@ -46,7 +47,6 @@ class FlowGraphCompiler;
class FlowGraphVisitor;
class Function;
class LocalVariable;
class LocationSummary;
// M is a two argument macro. It is applied to each concrete value's
// typename and classname.
@ -1706,6 +1706,7 @@ FOR_EACH_COMPUTATION(DEFINE_PREDICATE)
M(Throw) \
M(ReThrow) \
M(Branch) \
M(ParallelMove)
// Forward declarations for Instruction classes.
@ -2363,6 +2364,38 @@ class BranchInstr : public InstructionWithInputs {
DISALLOW_COPY_AND_ASSIGN(BranchInstr);
};
class MoveOperands : public ValueObject {
public:
MoveOperands(Location dest, Location src) : dest_(dest), src_(src) { }
Location src() const { return src_; }
Location dest() const { return dest_; }
private:
Location dest_;
Location src_;
};
class ParallelMoveInstr : public Instruction {
public:
ParallelMoveInstr() : moves_(1) { }
DECLARE_INSTRUCTION(ParallelMove)
void AddMove(Location dest, Location src) {
moves_.Add(MoveOperands(dest, src));
}
const GrowableArray<MoveOperands>& moves() { return moves_; }
private:
GrowableArray<MoveOperands> moves_;
DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr);
};
#undef DECLARE_INSTRUCTION

View file

@ -119,6 +119,8 @@
'flags.cc',
'flags.h',
'flags_test.cc',
'flow_graph_allocator.cc',
'flow_graph_allocator.h',
'flow_graph_builder.cc',
'flow_graph_builder.h',
'flow_graph_compiler.cc',