Add MCObjectFileInfo and sink the MCSections initialization code from
[oota-llvm.git] / tools / lto / LTOModule.h
index 367ad1026f012e2c605eeba3770ccbb68961bf40..0b64a902f91642927e0337a1ac65575b5639fc52 100644 (file)
@@ -32,15 +32,13 @@ namespace llvm {
     class GlobalValue;
     class Value;
     class Function;
-    class LLVMContext;
 }
 
 
 //
 // C++ class which implements the opaque lto_module_t
 //
-class LTOModule {
-public:
+struct LTOModule {
 
     static bool              isBitcodeFile(const void* mem, size_t length);
     static bool              isBitcodeFile(const char* path);
@@ -52,35 +50,46 @@ public:
                                                     const char* triplePrefix);
 
     static LTOModule*        makeLTOModule(const char* path,
-                                          llvm::LLVMContext& Context,
                                           std::string& errMsg);
+    static LTOModule*        makeLTOModule(int fd, const char *path,
+                                           size_t size,
+                                           std::string& errMsg);
+    static LTOModule*        makeLTOModule(int fd, const char *path,
+                                           size_t file_size,
+                                           size_t map_size,
+                                           off_t offset,
+                                           std::string& errMsg);
     static LTOModule*        makeLTOModule(const void* mem, size_t length,
-                                           llvm::LLVMContext& Context,
                                            std::string& errMsg);
 
     const char*              getTargetTriple();
+    void                     setTargetTriple(const char*);
     uint32_t                 getSymbolCount();
     lto_symbol_attributes    getSymbolAttributes(uint32_t index);
     const char*              getSymbolName(uint32_t index);
     
     llvm::Module *           getLLVVMModule() { return _module.get(); }
+    const std::vector<const char*> &getAsmUndefinedRefs() {
+            return _asm_undefines;
+    }
 
 private:
                             LTOModule(llvm::Module* m, llvm::TargetMachine* t);
 
-    void                    lazyParseSymbols();
+    bool                    ParseSymbols();
     void                    addDefinedSymbol(llvm::GlobalValue* def, 
                                                     llvm::Mangler& mangler, 
                                                     bool isFunction);
     void                    addPotentialUndefinedSymbol(llvm::GlobalValue* decl, 
                                                         llvm::Mangler &mangler);
-    void                    findExternalRefs(llvm::Value* value, 
-                                                llvm::Mangler& mangler);
     void                    addDefinedFunctionSymbol(llvm::Function* f, 
                                                         llvm::Mangler &mangler);
     void                    addDefinedDataSymbol(llvm::GlobalValue* v, 
                                                         llvm::Mangler &mangler);
-    void                    addAsmGlobalSymbol(const char *);
+    bool                    addAsmGlobalSymbols(llvm::MCContext &Context);
+    void                    addAsmGlobalSymbol(const char *,
+                                               lto_symbol_attributes scope);
+    void                    addAsmGlobalSymbolUndef(const char *);
     void                    addObjCClass(llvm::GlobalVariable* clgv);
     void                    addObjCCategory(llvm::GlobalVariable* clgv);
     void                    addObjCClassRef(llvm::GlobalVariable* clgv);
@@ -91,7 +100,6 @@ private:
                                                     const char* triplePrefix);
 
     static LTOModule*       makeLTOModule(llvm::MemoryBuffer* buffer,
-                                          llvm::LLVMContext& Context,
                                                         std::string& errMsg);
     static llvm::MemoryBuffer* makeBuffer(const void* mem, size_t length);
 
@@ -104,14 +112,12 @@ private:
 
     llvm::OwningPtr<llvm::Module>           _module;
     llvm::OwningPtr<llvm::TargetMachine>    _target;
-    bool                                    _symbolsParsed;
     std::vector<NameAndAttributes>          _symbols;
     // _defines and _undefines only needed to disambiguate tentative definitions
     StringSet                               _defines;    
     llvm::StringMap<NameAndAttributes>      _undefines;
+    std::vector<const char*>                _asm_undefines;
 };
 
-extern std::string getFeatureString(const char *TargetTriple);
-
 #endif // LTO_MODULE_H