Expand the pass to unify all of the unwind blocks as well
[oota-llvm.git] / include / llvm / Support / Annotation.h
index c444ce606626a835a736417321bc42771a30be82..f4b7c28202f10e88f05dbc14cfdad89991a50c8a 100644 (file)
@@ -1,23 +1,23 @@
-//===-- llvm/Annotation.h - Annotation classes -------------------*- C++ -*--=//
+//===-- Support/Annotation.h - Annotation classes ---------------*- C++ -*-===//
 //
 // This file contains the declarations for two classes: Annotation & Annotable.
 // Using these two simple classes, anything that derives from Annotable can have
 // Annotation subclasses attached to them, ready for easy retrieval.
 //
-// Annotations are designed to be easily attachable to LLVM code (as all Value's
-// are Annotable), and can even be serialized to bytecode and to assembly.
+// Annotations are designed to be easily attachable to various classes.
 //
-// The AnnotationManager class (defined in AnnotationManager.h) is essential for
-// using these classes.  It is responsible for turning Annotation name strings
-// into tokens [unique id #'s] that may be used to search for and create
-// annotations.
+// The AnnotationManager class is essential for using these classes.  It is
+// responsible for turning Annotation name strings into tokens [unique id #'s]
+// that may be used to search for and create annotations.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_ANNOTATION_H
-#define LLVM_ANNOTATION_H
+#ifndef SUPPORT_ANNOTATION_H
+#define SUPPORT_ANNOTATION_H
 
 #include <string>
+#include <cassert>
+
 class AnnotationID;
 class Annotation;
 class Annotable;
@@ -80,7 +80,10 @@ public:
 // ID#'s are stored sequentially.
 //
 class Annotable {
-  Annotation *AnnotationList;
+  mutable Annotation *AnnotationList;
+
+  Annotable(const Annotable &);        // Do not implement
+  void operator=(const Annotable &);   // Do not implement
 public:
   Annotable() : AnnotationList(0) {}
   virtual ~Annotable() {   // Virtual because it's designed to be subclassed...
@@ -107,11 +110,11 @@ public:
   // no annotation with the specified ID, then use the AnnotationManager to
   // create one.
   //
-  inline Annotation *getOrCreateAnnotation(AnnotationID ID);
+  inline Annotation *getOrCreateAnnotation(AnnotationID ID) const;
 
   // addAnnotation - Insert the annotation into the list in a sorted location.
   //
-  void addAnnotation(Annotation *A) {
+  void addAnnotation(Annotation *A) const {
     assert(A->Next == 0 && "Annotation already in list?!?");
 
     Annotation **AL = &AnnotationList;
@@ -124,7 +127,7 @@ public:
   // unlinkAnnotation - Remove the first annotation of the specified ID... and
   // then return the unlinked annotation.  The annotation object is not deleted.
   //
-  inline Annotation *unlinkAnnotation(AnnotationID ID) {
+  inline Annotation *unlinkAnnotation(AnnotationID ID) const {
     for (Annotation **A = &AnnotationList; *A; A = &((*A)->Next))
       if ((*A)->getID() == ID) {
        Annotation *Ret = *A;
@@ -138,7 +141,7 @@ public:
   // deleteAnnotation - Delete the first annotation of the specified ID in the
   // list.  Unlink unlinkAnnotation, this actually deletes the annotation object
   //
-  bool deleteAnnotation(AnnotationID ID) {
+  bool deleteAnnotation(AnnotationID ID) const {
     Annotation *A = unlinkAnnotation(ID);
     delete A;
     return A != 0;
@@ -161,12 +164,18 @@ public:
 // register an annotation handler 
 //
 struct AnnotationManager {
+  typedef Annotation *(*Factory)(AnnotationID, const Annotable *, void*);
+
   //===--------------------------------------------------------------------===//
   // Basic ID <-> Name map functionality
 
-  static AnnotationID  getID  (const string &Name);  // Name -> ID
-  static const string &getName(AnnotationID ID);     // ID -> Name
+  static AnnotationID         getID(const std::string &Name);  // Name -> ID
+  static const std::string &getName(AnnotationID ID);          // ID -> Name
 
+  // getID - Name -> ID + registration of a factory function for demand driven
+  // annotation support.
+  static AnnotationID getID(const std::string &Name, Factory Fact,
+                            void *Data = 0);
 
   //===--------------------------------------------------------------------===//
   // Annotation creation on demand support...
@@ -175,14 +184,13 @@ struct AnnotationManager {
   // function used to create an annotation on demand if it is needed by the 
   // Annotable::getOrCreateAnnotation method.
   //
-  static void registerAnnotationFactory(AnnotationID ID, 
-                          Annotation *(*Func)(AnnotationID, Annotable *, void*),
+  static void registerAnnotationFactory(AnnotationID ID, Factory Func,
                                        void *ExtraData = 0);
 
   // createAnnotation - Create an annotation of the specified ID for the
   // specified object, using a register annotation creation function.
   //
-  static Annotation *createAnnotation(AnnotationID ID, Annotable *Obj);
+  static Annotation *createAnnotation(AnnotationID ID, const Annotable *Obj);
 };
 
 
@@ -191,7 +199,7 @@ struct AnnotationManager {
 // no annotation with the specified ID, then use the AnnotationManager to
 // create one.
 //
-inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) {
+inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) const {
   Annotation *A = getAnnotation(ID);   // Fast path, check for preexisting ann
   if (A) return A;