From 674c0377f5af458050e561619c7a34c301f54f30 Mon Sep 17 00:00:00 2001 From: Benjamin Segovia Date: Mon, 8 Oct 2012 19:39:33 +0000 Subject: [PATCH] Used intrusive_list for SelectionVector --- backend/src/backend/gen_insn_selection.cpp | 10 +++------- backend/src/backend/gen_insn_selection.hpp | 10 ++++------ backend/src/backend/gen_reg_allocation.cpp | 11 +++-------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp index c247310..2097b10 100644 --- a/backend/src/backend/gen_insn_selection.cpp +++ b/backend/src/backend/gen_insn_selection.cpp @@ -76,16 +76,14 @@ namespace gbe /////////////////////////////////////////////////////////////////////////// SelectionVector::SelectionVector(void) : - insn(NULL), next(NULL), reg(NULL), regNum(0), isSrc(0) + insn(NULL), reg(NULL), regNum(0), isSrc(0) {} /////////////////////////////////////////////////////////////////////////// // SelectionBlock /////////////////////////////////////////////////////////////////////////// - SelectionBlock::SelectionBlock(const ir::BasicBlock *bb) : - vector(NULL), bb(bb) - {} + SelectionBlock::SelectionBlock(const ir::BasicBlock *bb) : bb(bb) {} void SelectionBlock::append(ir::Register reg) { tmp.push_back(reg); } @@ -100,9 +98,7 @@ namespace gbe } void SelectionBlock::append(SelectionVector *vec) { - SelectionVector *tmp = this->vector; - this->vector = vec; - this->vector->next = tmp; + this->vectorList.push_back(vec); } /////////////////////////////////////////////////////////////////////////// diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp index 1716143..c07b8fd 100644 --- a/backend/src/backend/gen_insn_selection.hpp +++ b/backend/src/backend/gen_insn_selection.hpp @@ -150,14 +150,12 @@ namespace gbe }; /*! Instructions like sends require to make registers contiguous in GRF */ - class SelectionVector + class SelectionVector : public NonCopyable, public intrusive_list_node { public: SelectionVector(void); /*! The instruction that requires the vector of registers */ SelectionInstruction *insn; - /*! We chain the selection vectors together */ - SelectionVector *next; /*! Directly points to the selection instruction registers */ GenRegister *reg; /*! Number of registers in the vector */ @@ -179,19 +177,19 @@ namespace gbe /*! All the emitted instructions in the block */ intrusive_list insnList; /*! The vectors that may be required by some instructions of the block */ - SelectionVector *vector; + intrusive_list vectorList; /*! Extra registers needed by the block (only live in the block) */ gbe::vector tmp; /*! Associated IR basic block */ const ir::BasicBlock *bb; /*! Append a new temporary register */ void append(ir::Register reg); + /*! Append a new selection vector in the block */ + void append(SelectionVector *vec); /*! Append a new selection instruction at the end of the block */ void append(SelectionInstruction *insn); /*! Append a new selection instruction at the beginning of the block */ void prepend(SelectionInstruction *insn); - /*! Append a new selection vector in the block */ - void append(SelectionVector *vec); }; /*! Owns the selection engine */ diff --git a/backend/src/backend/gen_reg_allocation.cpp b/backend/src/backend/gen_reg_allocation.cpp index 4fa335a..7460d70 100644 --- a/backend/src/backend/gen_reg_allocation.cpp +++ b/backend/src/backend/gen_reg_allocation.cpp @@ -223,14 +223,9 @@ namespace gbe // First we find and store all vectors uint32_t vectorID = 0; - for (auto &block : *selection.blockList) { - SelectionVector *v = block.vector; - while (v) { - GBE_ASSERT(vectorID < vectorNum); - this->vectors[vectorID++] = v; - v = v->next; - } - } + for (auto &block : *selection.blockList) + for (auto &v : block.vectorList) + this->vectors[vectorID++] = &v; GBE_ASSERT(vectorID == vectorNum); // Heuristic (really simple...): sort them by the number of registers they -- 2.7.4