Add MachineBasicBlock2IndexFunctor. This is useful for densemaps from
[oota-llvm.git] / include / llvm / CodeGen / MachineBasicBlock.h
index 9d4ede6de1fabf02784dad24e54f12aaf4a2d57d..fb037402903d249b8b436783dfc9f5187328a41f 100644 (file)
@@ -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<const MachineBasicBlock*, unsigned> {
+  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)