From: Alkis Evlogimenos Date: Fri, 27 Aug 2004 04:00:26 +0000 (+0000) Subject: Add MachineBasicBlock2IndexFunctor. This is useful for densemaps from X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6177d3f4481ef622ce8cc19bbde8709214881aec;p=oota-llvm.git Add MachineBasicBlock2IndexFunctor. This is useful for densemaps from MachineBasicBlocks to an arbitrary type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16068 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index 9d4ede6de1f..fb037402903 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -220,6 +220,16 @@ private: // Methods used to maintain doubly linked list of blocks... } }; +// This is useful when building DenseMaps keyed on MachineBasicBlocks +struct MachineBasicBlock2IndexFunctor + : std::unary_function { + unsigned operator()(const MachineBasicBlock* MBB) const { + assert(MBB->getNumber() != -1 && + "MachineBasicBlock does not belong to a MachineFunction"); + return MBB->getNumber(); + } +}; + //===--------------------------------------------------------------------===// // GraphTraits specializations for machine basic block graphs (machine-CFGs)