Use Function's arg_size() and size() methods.
[oota-llvm.git] / include / llvm / LinkTimeOptimizer.h
index c126bb23620a1a57055257290a2236819c233435..eea0093e80f7caa3ec8a397400d465fdea12b27f 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Devang Patel and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 // 
 //===----------------------------------------------------------------------===//
 //
@@ -19,6 +19,9 @@
 #include <vector>
 #include <set>
 #include <llvm/ADT/hash_map>
+#include <cstring>
+
+#define LLVM_LTO_VERSION 2
 
 namespace llvm {
 
@@ -42,7 +45,21 @@ namespace llvm {
     LTOExternalLinkage, // Externally visible function
     LTOLinkOnceLinkage, // Keep one copy of named function when linking (inline)
     LTOWeakLinkage,     // Keep one copy of named function when linking (weak)
-    LTOInternalLinkage  // Rename collisions when linking (static functions)
+    LTOInternalLinkage, // Rename collisions when linking (static functions)
+    LTOCommonLinkage    // tentative definitions (usually equivalent to weak)
+  };
+
+  enum LTOVisibilityTypes {
+    LTODefaultVisibility = 0,  ///< The GV is visible
+    LTOHiddenVisibility,       ///< The GV is hidden
+    LTOProtectedVisibility     ///< The GV is protected
+  };
+
+
+  enum LTOCodeGenModel {
+    LTO_CGM_Static,
+    LTO_CGM_Dynamic,
+    LTO_CGM_DynamicNoPIC
   };
 
   /// This class represents LLVM symbol information without exposing details
@@ -54,10 +71,13 @@ namespace llvm {
   public:
 
     LTOLinkageTypes getLinkage() const { return linkage; }
+    LTOVisibilityTypes getVisibility() const { return visibility; }
     void mayBeNotUsed();
 
-    LLVMSymbol (enum LTOLinkageTypes lt, GlobalValue *g, const std::string &n, 
-                const std::string &m, int a) : linkage(lt), gv(g), name(n), 
+    LLVMSymbol (enum LTOLinkageTypes lt, enum LTOVisibilityTypes vis, 
+                GlobalValue *g, const std::string &n, 
+                const std::string &m, int a) : linkage(lt), visibility(vis),
+                                               gv(g), name(n), 
                                                mangledName(m), alignment(a) {}
 
     const char *getName() { return name.c_str(); }
@@ -66,6 +86,7 @@ namespace llvm {
 
   private:
     enum LTOLinkageTypes linkage;
+    enum LTOVisibilityTypes visibility;
     GlobalValue *gv;
     std::string name;
     std::string mangledName;
@@ -91,10 +112,13 @@ namespace llvm {
                                               NameToSymbolMap &,
                                               std::set<std::string> &) = 0;
     virtual enum LTOStatus optimizeModules(const std::string &,
-                                   std::vector<const char*> &,
-                                   std::string &) = 0;
+                                           std::vector<const char*> &exportList,
+                                           std::string &targetTriple,
+                                           bool saveTemps, const char *) = 0;
     virtual void getTargetTriple(const std::string &, std::string &) = 0;
     virtual void removeModule (const std::string &InputFilename) = 0;
+    virtual void setCodeGenModel(LTOCodeGenModel CGM) = 0;
+    virtual void printVersion () = 0;
     virtual ~LinkTimeOptimizer() = 0;
   };
 
@@ -113,14 +137,20 @@ namespace llvm {
                                       std::set<std::string> &references);
     enum LTOStatus optimizeModules(const std::string &OutputFilename,
                                    std::vector<const char*> &exportList,
-                                   std::string &targetTriple);
-    void getTargetTriple(const std::string &InputFilename, std::string &targetTriple);
+                                   std::string &targetTriple, 
+                                   bool saveTemps,  const char *);
+    void getTargetTriple(const std::string &InputFilename, 
+                         std::string &targetTriple);
     void removeModule (const std::string &InputFilename);
+    void printVersion();
+
+    void setCodeGenModel(LTOCodeGenModel CGM) {
+      CGModel = CGM;
+    }
 
     // Constructors and destructors
-    LTO() 
+    LTO() : Target(NULL), CGModel(LTO_CGM_Dynamic) {
       /// TODO: Use Target info, it is available at this time.
-      Target = NULL; 
     }
     ~LTO();
 
@@ -135,6 +165,7 @@ namespace llvm {
     NameToSymbolMap allSymbols;
     NameToModuleMap allModules;
     TargetMachine *Target;
+    LTOCodeGenModel CGModel;
   };
 
 } // End llvm namespace
@@ -143,6 +174,6 @@ namespace llvm {
 /// linker to use dlopen() interface to dynamically load LinkTimeOptimizer.
 /// extern "C" helps, because dlopen() interface uses name to find the symbol.
 extern "C"
-llvm::LinkTimeOptimizer *createLLVMOptimizer();
+llvm::LinkTimeOptimizer *createLLVMOptimizer(unsigned VERSION = LLVM_LTO_VERSION);
 
 #endif