Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: src/compiler/instruction.h

Issue 664683002: [turbofan] decouple register allocation from schedule and graph (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/instruction.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction.h
diff --git a/src/compiler/instruction.h b/src/compiler/instruction.h
index fc4778f8949f9be318ead5e53d707cae25bae169..0c7ce81f94e8042bb40bc428aee8fa6bd034d710 100644
--- a/src/compiler/instruction.h
+++ b/src/compiler/instruction.h
@@ -753,6 +753,81 @@ class FrameStateDescriptor : public ZoneObject {
std::ostream& operator<<(std::ostream& os, const Constant& constant);
+
+// TODO(dcarney): this is a temporary hack. turn into an actual instruction.
+class PhiInstruction : public ZoneObject {
+ public:
+ PhiInstruction(Zone* zone, int virtual_register)
+ : virtual_register_(virtual_register), operands_(zone) {}
+
+ int virtual_register() const { return virtual_register_; }
+ const IntVector& operands() const { return operands_; }
+ IntVector& operands() { return operands_; }
+
+ private:
+ const int virtual_register_;
+ IntVector operands_;
+};
+
+
+// Analogue of BasicBlock for Instructions instead of Nodes.
+class InstructionBlock : public ZoneObject {
+ public:
+ explicit InstructionBlock(Zone* zone, const BasicBlock* block);
+
+ // Instruction indexes (used by the register allocator).
+ int first_instruction_index() const {
+ DCHECK(code_start_ >= 0);
+ DCHECK(code_end_ > 0);
+ DCHECK(code_end_ >= code_start_);
+ return code_start_;
+ }
+ int last_instruction_index() const {
+ DCHECK(code_start_ >= 0);
+ DCHECK(code_end_ > 0);
+ DCHECK(code_end_ >= code_start_);
+ return code_end_ - 1;
+ }
+
+ int32_t code_start() const { return code_start_; }
+ void set_code_start(int32_t start) { code_start_ = start; }
+
+ int32_t code_end() const { return code_end_; }
+ void set_code_end(int32_t end) { code_end_ = end; }
+
+ BasicBlock::RpoNumber rpo_number() const { return rpo_number_; }
+ BasicBlock::RpoNumber loop_header() const { return loop_header_; }
+ BasicBlock::RpoNumber loop_end() const {
+ DCHECK(IsLoopHeader());
+ return loop_end_;
+ }
+ inline bool IsLoopHeader() const { return loop_end_.IsValid(); }
+
+ typedef ZoneVector<BasicBlock::RpoNumber> Predecessors;
+ const Predecessors& predecessors() const { return predecessors_; }
+ size_t PredecessorCount() const { return predecessors_.size(); }
+ size_t PredecessorIndexOf(BasicBlock::RpoNumber rpo_number) const;
+
+ typedef ZoneVector<BasicBlock::RpoNumber> Successors;
+ const Successors& successors() const { return successors_; }
+ size_t SuccessorCount() const { return successors_.size(); }
+
+ typedef ZoneVector<PhiInstruction*> PhiInstructions;
+ const PhiInstructions& phis() const { return phis_; }
+ void AddPhi(PhiInstruction* phi) { phis_.push_back(phi); }
+
+ private:
+ Successors successors_;
+ Predecessors predecessors_;
+ PhiInstructions phis_;
+ // TODO(dcarney): probably dont't need this.
+ BasicBlock::RpoNumber rpo_number_;
+ BasicBlock::RpoNumber loop_header_;
+ BasicBlock::RpoNumber loop_end_;
+ int32_t code_start_; // start index of arch-specific code.
+ int32_t code_end_; // end index of arch-specific code.
+};
+
typedef ZoneDeque<Constant> ConstantDeque;
typedef std::map<int, Constant, std::less<int>,
zone_allocator<std::pair<int, Constant> > > ConstantMap;
@@ -760,6 +835,7 @@ typedef std::map<int, Constant, std::less<int>,
typedef ZoneDeque<Instruction*> InstructionDeque;
typedef ZoneDeque<PointerMap*> PointerMapDeque;
typedef ZoneVector<FrameStateDescriptor*> DeoptimizationVector;
+typedef ZoneVector<InstructionBlock*> InstructionBlocks;
// Represents architecture-specific generated code before, during, and after
// register allocation.
@@ -774,18 +850,32 @@ class InstructionSequence FINAL {
int node_count() const { return node_count_; }
int BasicBlockCount() const {
- return static_cast<int>(schedule_->rpo_order()->size());
+ return static_cast<int>(instruction_blocks_.size());
}
BasicBlock* BlockAt(int rpo_number) const {
return (*schedule_->rpo_order())[rpo_number];
}
- BasicBlock* GetContainingLoop(BasicBlock* block) {
- return block->loop_header();
+ InstructionBlock* InstructionBlockAt(BasicBlock::RpoNumber rpo_number) {
+ return GetBlock(rpo_number);
+ }
+
+ const InstructionBlock* InstructionBlockAt(
+ BasicBlock::RpoNumber rpo_number) const {
+ return GetBlock(rpo_number);
+ }
+
+ // TODO(dcarney): move to register allocator.
+ const InstructionBlock* GetContainingLoop(
+ const InstructionBlock* block) const {
+ BasicBlock::RpoNumber index = block->loop_header();
+ if (!index.IsValid()) return NULL;
+ return instruction_blocks_[index.ToInt()];
}
BasicBlock* GetBasicBlock(int instruction_index);
+ const InstructionBlock* GetInstructionBlock(int instruction_index) const;
int GetVirtualRegister(const Node* node);
// TODO(dcarney): find a way to remove this.
@@ -828,26 +918,32 @@ class InstructionSequence FINAL {
void StartBlock(BasicBlock* block);
void EndBlock(BasicBlock* block);
void set_code_start(BasicBlock* block, int start) {
- return GetBlockData(block->GetRpoNumber()).set_code_start(start);
+ return GetBlock(block->GetRpoNumber())->set_code_start(start);
}
void set_code_end(BasicBlock* block, int end) {
- return GetBlockData(block->GetRpoNumber()).set_code_end(end);
+ return GetBlock(block->GetRpoNumber())->set_code_end(end);
}
// TODO(dcarney): use RpoNumber for all of the below.
int code_start(BasicBlock::RpoNumber rpo_number) const {
- return GetBlockData(rpo_number).code_start();
+ return GetBlock(rpo_number)->code_start();
}
int code_start(BasicBlock* block) const {
- return GetBlockData(block->GetRpoNumber()).code_start();
+ return GetBlock(block->GetRpoNumber())->code_start();
}
int code_end(BasicBlock* block) const {
- return GetBlockData(block->GetRpoNumber()).code_end();
+ return GetBlock(block->GetRpoNumber())->code_end();
}
int first_instruction_index(BasicBlock* block) const {
- return GetBlockData(block->GetRpoNumber()).first_instruction_index();
+ return GetBlock(block->GetRpoNumber())->first_instruction_index();
}
int last_instruction_index(BasicBlock* block) const {
- return GetBlockData(block->GetRpoNumber()).last_instruction_index();
+ return GetBlock(block->GetRpoNumber())->last_instruction_index();
+ }
+ int first_instruction_index(InstructionBlock* block) const {
+ return GetBlock(block->rpo_number())->first_instruction_index();
+ }
+ int last_instruction_index(InstructionBlock* block) const {
+ return GetBlock(block->rpo_number())->last_instruction_index();
}
int AddConstant(Node* node, Constant constant) {
@@ -892,51 +988,19 @@ class InstructionSequence FINAL {
int GetFrameStateDescriptorCount();
private:
- class BlockData {
- public:
- BlockData() : code_start_(-1), code_end_(-1) {}
- // Instruction indexes (used by the register allocator).
- int first_instruction_index() const {
- DCHECK(code_start_ >= 0);
- DCHECK(code_end_ > 0);
- DCHECK(code_end_ >= code_start_);
- return code_start_;
- }
- int last_instruction_index() const {
- DCHECK(code_start_ >= 0);
- DCHECK(code_end_ > 0);
- DCHECK(code_end_ >= code_start_);
- return code_end_ - 1;
- }
-
- int32_t code_start() const { return code_start_; }
- void set_code_start(int32_t start) { code_start_ = start; }
-
- int32_t code_end() const { return code_end_; }
- void set_code_end(int32_t end) { code_end_ = end; }
-
- private:
- int32_t code_start_; // start index of arch-specific code.
- int32_t code_end_; // end index of arch-specific code.
- };
-
- const BlockData& GetBlockData(BasicBlock::RpoNumber rpo_number) const {
- return block_data_[rpo_number.ToSize()];
- }
- BlockData& GetBlockData(BasicBlock::RpoNumber rpo_number) {
- return block_data_[rpo_number.ToSize()];
+ InstructionBlock* GetBlock(BasicBlock::RpoNumber rpo_number) const {
+ return instruction_blocks_[rpo_number.ToSize()];
}
friend std::ostream& operator<<(std::ostream& os,
const InstructionSequence& code);
typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
- typedef ZoneVector<BlockData> BlockDataVector;
Zone* zone_;
int node_count_;
int* node_map_;
- BlockDataVector block_data_;
+ InstructionBlocks instruction_blocks_;
Linkage* linkage_;
Schedule* schedule_;
ConstantMap constants_;
« no previous file with comments | « no previous file | src/compiler/instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698