Move LOperand class to lithium.h and move implementations out of .h into .cc files.

Review URL: http://codereview.chromium.org/6378004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6400 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 93a0b806
......@@ -37,7 +37,7 @@
#include "full-codegen.h"
#include "gdb-jit.h"
#include "hydrogen.h"
#include "lithium-allocator.h"
#include "lithium.h"
#include "liveedit.h"
#include "oprofile-agent.h"
#include "parser.h"
......
......@@ -30,7 +30,7 @@
#include "v8.h"
#include "lithium-allocator.h"
#include "lithium.h"
namespace v8 {
namespace internal {
......
......@@ -71,73 +71,24 @@ static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) {
}
void LOperand::PrintTo(StringStream* stream) {
LUnallocated* unalloc = NULL;
switch (kind()) {
case INVALID:
break;
case UNALLOCATED:
unalloc = LUnallocated::cast(this);
stream->Add("v%d", unalloc->virtual_register());
switch (unalloc->policy()) {
case LUnallocated::NONE:
break;
case LUnallocated::FIXED_REGISTER: {
const char* register_name =
Register::AllocationIndexToString(unalloc->fixed_index());
stream->Add("(=%s)", register_name);
break;
}
case LUnallocated::FIXED_DOUBLE_REGISTER: {
const char* double_register_name =
DoubleRegister::AllocationIndexToString(unalloc->fixed_index());
stream->Add("(=%s)", double_register_name);
break;
}
case LUnallocated::FIXED_SLOT:
stream->Add("(=%dS)", unalloc->fixed_index());
break;
case LUnallocated::MUST_HAVE_REGISTER:
stream->Add("(R)");
break;
case LUnallocated::WRITABLE_REGISTER:
stream->Add("(WR)");
break;
case LUnallocated::SAME_AS_FIRST_INPUT:
stream->Add("(1)");
break;
case LUnallocated::ANY:
stream->Add("(-)");
break;
case LUnallocated::IGNORE:
stream->Add("(0)");
break;
}
break;
case CONSTANT_OPERAND:
stream->Add("[constant:%d]", index());
break;
case STACK_SLOT:
stream->Add("[stack:%d]", index());
break;
case DOUBLE_STACK_SLOT:
stream->Add("[double_stack:%d]", index());
break;
case REGISTER:
stream->Add("[%s|R]", Register::AllocationIndexToString(index()));
break;
case DOUBLE_REGISTER:
stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index()));
break;
case ARGUMENT:
stream->Add("[arg:%d]", index());
break;
UsePosition::UsePosition(LifetimePosition pos, LOperand* operand)
: operand_(operand),
hint_(NULL),
pos_(pos),
next_(NULL),
requires_reg_(false),
register_beneficial_(true) {
if (operand_ != NULL && operand_->IsUnallocated()) {
LUnallocated* unalloc = LUnallocated::cast(operand_);
requires_reg_ = unalloc->HasRegisterPolicy();
register_beneficial_ = !unalloc->HasAnyPolicy();
}
ASSERT(pos_.IsValid());
}
int LOperand::VirtualRegister() {
LUnallocated* unalloc = LUnallocated::cast(this);
return unalloc->virtual_register();
bool UsePosition::HasHint() const {
return hint_ != NULL && !hint_->IsUnallocated();
}
......@@ -190,6 +141,53 @@ bool LiveRange::HasOverlap(UseInterval* target) const {
#endif
LiveRange::LiveRange(int id)
: id_(id),
spilled_(false),
assigned_register_(kInvalidAssignment),
assigned_register_kind_(NONE),
last_interval_(NULL),
first_interval_(NULL),
first_pos_(NULL),
parent_(NULL),
next_(NULL),
current_interval_(NULL),
last_processed_use_(NULL),
spill_start_index_(kMaxInt) {
spill_operand_ = new LUnallocated(LUnallocated::IGNORE);
}
void LiveRange::set_assigned_register(int reg, RegisterKind register_kind) {
ASSERT(!HasRegisterAssigned() && !IsSpilled());
assigned_register_ = reg;
assigned_register_kind_ = register_kind;
ConvertOperands();
}
void LiveRange::MakeSpilled() {
ASSERT(!IsSpilled());
ASSERT(TopLevel()->HasAllocatedSpillOperand());
spilled_ = true;
assigned_register_ = kInvalidAssignment;
ConvertOperands();
}
bool LiveRange::HasAllocatedSpillOperand() const {
return spill_operand_ != NULL && !spill_operand_->IsUnallocated();
}
void LiveRange::SetSpillOperand(LOperand* operand) {
ASSERT(!operand->IsUnallocated());
ASSERT(spill_operand_ != NULL);
ASSERT(spill_operand_->IsUnallocated());
spill_operand_->ConvertTo(operand->kind(), operand->index());
}
UsePosition* LiveRange::NextUsePosition(LifetimePosition start) {
UsePosition* use_pos = last_processed_use_;
if (use_pos == NULL) use_pos = first_pos();
......
This diff is collapsed.
......@@ -30,6 +30,78 @@
namespace v8 {
namespace internal {
void LOperand::PrintTo(StringStream* stream) {
LUnallocated* unalloc = NULL;
switch (kind()) {
case INVALID:
break;
case UNALLOCATED:
unalloc = LUnallocated::cast(this);
stream->Add("v%d", unalloc->virtual_register());
switch (unalloc->policy()) {
case LUnallocated::NONE:
break;
case LUnallocated::FIXED_REGISTER: {
const char* register_name =
Register::AllocationIndexToString(unalloc->fixed_index());
stream->Add("(=%s)", register_name);
break;
}
case LUnallocated::FIXED_DOUBLE_REGISTER: {
const char* double_register_name =
DoubleRegister::AllocationIndexToString(unalloc->fixed_index());
stream->Add("(=%s)", double_register_name);
break;
}
case LUnallocated::FIXED_SLOT:
stream->Add("(=%dS)", unalloc->fixed_index());
break;
case LUnallocated::MUST_HAVE_REGISTER:
stream->Add("(R)");
break;
case LUnallocated::WRITABLE_REGISTER:
stream->Add("(WR)");
break;
case LUnallocated::SAME_AS_FIRST_INPUT:
stream->Add("(1)");
break;
case LUnallocated::ANY:
stream->Add("(-)");
break;
case LUnallocated::IGNORE:
stream->Add("(0)");
break;
}
break;
case CONSTANT_OPERAND:
stream->Add("[constant:%d]", index());
break;
case STACK_SLOT:
stream->Add("[stack:%d]", index());
break;
case DOUBLE_STACK_SLOT:
stream->Add("[double_stack:%d]", index());
break;
case REGISTER:
stream->Add("[%s|R]", Register::AllocationIndexToString(index()));
break;
case DOUBLE_REGISTER:
stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index()));
break;
case ARGUMENT:
stream->Add("[arg:%d]", index());
break;
}
}
int LOperand::VirtualRegister() {
LUnallocated* unalloc = LUnallocated::cast(this);
return unalloc->virtual_register();
}
bool LParallelMove::IsRedundant() const {
for (int i = 0; i < move_operands_.length(); ++i) {
if (!move_operands_[i].IsRedundant()) return false;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment