Vector is my friend, do you like vector?
[oota-llvm.git] / include / llvm / Function.h
index 885824d4f7e7f191873dfa7e96834c68f1950953..29046ad78227efeb8a7038c58248fef4b38b77fb 100644 (file)
@@ -71,8 +71,8 @@ public:
   /// function is automatically inserted into the end of the function list for
   /// the module.
   ///
-  Function(const FunctionType *Ty, bool isInternal, const std::string &N = "",
-           Module *M = 0);
+  Function(const FunctionType *Ty, LinkageTypes Linkage,
+           const std::string &N = "", Module *M = 0);
   ~Function();
 
   // Specialize setName to handle symbol table majik...
@@ -87,6 +87,23 @@ public:
   ///
   virtual bool isExternal() const { return BasicBlocks.empty(); }
 
+  /// getIntrinsicID - This method returns the ID number of the specified
+  /// function, or LLVMIntrinsic::not_intrinsic if the function is not an
+  /// instrinsic, or if the pointer is null.  This value is always defined to be
+  /// zero to allow easy checking for whether a function is intrinsic or not.
+  /// The particular intrinsic functions which correspond to this value are
+  /// defined in llvm/Intrinsics.h.
+  ///
+  unsigned getIntrinsicID() const;
+  bool isIntrinsic() const { return getIntrinsicID() != 0; }
+
+  /// deleteBody - This method deletes the body of the function, and converts
+  /// the linkage to external.
+  void deleteBody() {
+    dropAllReferences();
+    setLinkage(ExternalLinkage);
+  }
+
   // getNext/Prev - Return the next or previous function in the list.  These
   // methods should never be used directly, and are only used to implement the
   // function list as part of the module.
@@ -96,8 +113,8 @@ public:
         Function *getPrev()       { return Prev; }
   const Function *getPrev() const { return Prev; }
 
-  /// Get the underlying elements of the Function... both the argument list and
-  /// basic block list are empty for external functions.
+  /// Get the underlying elements of the Function... the basic block list is
+  /// empty for external functions.
   ///
   const ArgumentListType &getArgumentList() const { return ArgumentList; }
         ArgumentListType &getArgumentList()       { return ArgumentList; }
@@ -105,8 +122,8 @@ public:
   const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
         BasicBlockListType &getBasicBlockList()       { return BasicBlocks; }
 
-  const BasicBlock       &getEntryNode() const   { return front(); }
-        BasicBlock       &getEntryNode()         { return front(); }
+  const BasicBlock       &getEntryBlock() const   { return front(); }
+        BasicBlock       &getEntryBlock()         { return front(); }
 
   //===--------------------------------------------------------------------===//
   // Symbol Table Accessing functions...
@@ -165,14 +182,18 @@ public:
     return V->getValueType() == Value::FunctionVal;
   }
 
-  /// dropAllReferences() - This function causes all the subinstructions to "let
+  /// dropAllReferences() - This method causes all the subinstructions to "let
   /// go" of all references that they are maintaining.  This allows one to
-  /// 'delete' a whole class at a time, even though there may be circular
+  /// 'delete' a whole module at a time, even though there may be circular
   /// references... first all references are dropped, and all use counts go to
   /// zero.  Then everything is delete'd for real.  Note that no operations are
   /// valid on an object that has "dropped all references", except operator 
   /// delete.
   ///
+  /// Since no other object in the module can have references into the body of a
+  /// function, dropping all references deletes the entire body of the function,
+  /// including any contained basic blocks.
+  ///
   void dropAllReferences();
 };