From 94dc07728f091c652f0a8059aba6dce5018485ee Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Thu, 12 Feb 2004 19:12:03 +0000 Subject: [PATCH] Move ilist_trairs in MachineBasicBlock. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11358 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineBasicBlock.h | 47 +++++++++++++++++++++++ include/llvm/CodeGen/MachineInstr.h | 49 +----------------------- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 94409c5ef4c..e89b64eea61 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -15,9 +15,56 @@ #define LLVM_CODEGEN_MACHINEBASICBLOCK_H #include "llvm/CodeGen/MachineInstr.h" +#include "Support/ilist" namespace llvm { +// ilist_traits +template <> +class ilist_traits +{ + typedef ilist_traits self; + + // this is only set by the MachineBasicBlock owning the ilist + friend class MachineBasicBlock; + MachineBasicBlock* parent; + +public: + ilist_traits() : parent(0) { } + + static MachineInstr* getPrev(MachineInstr* N) { return N->prev; } + static MachineInstr* getNext(MachineInstr* N) { return N->next; } + + static const MachineInstr* + getPrev(const MachineInstr* N) { return N->prev; } + + static const MachineInstr* + getNext(const MachineInstr* N) { return N->next; } + + static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } + static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } + + static MachineInstr* createNode() { return new MachineInstr(0, 0); } + + void addNodeToList(MachineInstr* N) { + assert(N->parent == 0 && "machine instruction already in a basic block"); + N->parent = parent; + } + + void removeNodeFromList(MachineInstr* N) { + assert(N->parent != 0 && "machine instruction not in a basic block"); + N->parent = 0; + } + + void transferNodesFromList(iplist& toList, + ilist_iterator first, + ilist_iterator last) { + if (parent != toList.parent) + for (; first != last; ++first) + first->parent = toList.parent; + } +}; + class BasicBlock; class MachineBasicBlock { diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 8f010917c6c..5e8845eb451 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -17,7 +17,7 @@ #define LLVM_CODEGEN_MACHINEINSTR_H #include "Support/Annotation.h" -#include "Support/ilist" +#include "Support/iterator" #include namespace llvm { @@ -348,6 +348,7 @@ private: // Intrusive list support // friend class ilist_traits; + MachineInstr() : Opcode(0), numImplicitRefs(0) { /* used only by ilist */ } public: MachineInstr(short Opcode, unsigned numOperands); @@ -694,52 +695,6 @@ public: } }; -// ilist_traits -template <> -class ilist_traits -{ - typedef ilist_traits self; - - // this is only set by the MachineBasicBlock owning the ilist - friend class MachineBasicBlock; - MachineBasicBlock* parent; - -public: - ilist_traits() : parent(0) { } - - static MachineInstr* getPrev(MachineInstr* N) { return N->prev; } - static MachineInstr* getNext(MachineInstr* N) { return N->next; } - - static const MachineInstr* - getPrev(const MachineInstr* N) { return N->prev; } - - static const MachineInstr* - getNext(const MachineInstr* N) { return N->next; } - - static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; } - static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; } - - static MachineInstr* createNode() { return new MachineInstr(0, 0); } - - void addNodeToList(MachineInstr* N) { - assert(N->parent == 0 && "machine instruction already in a basic block"); - N->parent = parent; - } - - void removeNodeFromList(MachineInstr* N) { - assert(N->parent != 0 && "machine instruction not in a basic block"); - N->parent = 0; - } - - void transferNodesFromList(iplist& toList, - ilist_iterator first, - ilist_iterator last) { - if (parent != toList.parent) - for (; first != last; ++first) - first->parent = toList.parent; - } -}; - //===----------------------------------------------------------------------===// // Debugging Support -- 2.34.1