llvm.org GIT mirror llvm / c7cfbc5
Use abstract class to facilitate dlopen() interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30569 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 13 years ago
2 changed file(s) with 25 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
7474 return (strcmp(left, right) == 0);
7575 }
7676 };
77
77
78 /// This is abstract class to facilitate dlopen() interface.
79 /// See LTO below for more info.
80 class LinkTimeOptimizer {
81 public:
82 typedef hash_map,
83 string_compare> NameToSymbolMap;
84 typedef hash_map,
85 string_compare> NameToModuleMap;
86 virtual enum LTOStatus readLLVMObjectFile(const std::string &,
87 NameToSymbolMap &,
88 std::set &) = 0;
89 virtual enum LTOStatus optimizeModules(const std::string &,
90 std::vector &,
91 std::string &) = 0;
92 virtual void getTargetTriple(const std::string &, std::string &) = 0;
93 virtual ~LinkTimeOptimizer() = 0;
94 };
95
7896 /// This is the main link time optimization class. It exposes simple API
7997 /// to perform link time optimization using LLVM intermodular optimizer.
80 class LinkTimeOptimizer {
98 class LTO : public LinkTimeOptimizer {
8199
82100 public:
83101 typedef hash_map,
4343 extern "C"
4444 llvm::LinkTimeOptimizer *createLLVMOptimizer()
4545 {
46 llvm::LinkTimeOptimizer *l = new llvm::LinkTimeOptimizer();
46 llvm::LTO *l = new llvm::LTO();
4747 return l;
4848 }
4949
104104 /// InputFilename is a LLVM bytecode file. If Module with InputFilename is
105105 /// available then return it. Otherwise parseInputFilename.
106106 Module *
107 LinkTimeOptimizer::getModule(const std::string &InputFilename)
107 LTO::getModule(const std::string &InputFilename)
108108 {
109109 Module *m = NULL;
110110
121121 /// InputFilename is a LLVM bytecode file. Reade this bytecode file and
122122 /// set corresponding target triplet string.
123123 void
124 LinkTimeOptimizer::getTargetTriple(const std::string &InputFilename,
124 LTO::getTargetTriple(const std::string &InputFilename,
125125 std::string &targetTriple)
126126 {
127127 Module *m = getModule(InputFilename);
134134 /// Collect external references in references vector.
135135 /// Return LTO_READ_SUCCESS if there is no error.
136136 enum LTOStatus
137 LinkTimeOptimizer::readLLVMObjectFile(const std::string &InputFilename,
137 LTO::readLLVMObjectFile(const std::string &InputFilename,
138138 NameToSymbolMap &symbols,
139139 std::set &references)
140140 {
309309 /// native object file using OutputFilename
310310 /// Return appropriate LTOStatus.
311311 enum LTOStatus
312 LinkTimeOptimizer::optimizeModules(const std::string &OutputFilename,
312 LTO::optimizeModules(const std::string &OutputFilename,
313313 std::vector &exportList,
314314 std::string &targetTriple)
315315 {