mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-03 14:31:10 +00:00
Use abstract class to facilitate dlopen() interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30569 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d1aed7aaf7
commit
c7cfbc58ad
@ -75,10 +75,28 @@ namespace llvm {
|
|||||||
return (strcmp(left, right) == 0);
|
return (strcmp(left, right) == 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// This is abstract class to facilitate dlopen() interface.
|
||||||
|
/// See LTO below for more info.
|
||||||
|
class LinkTimeOptimizer {
|
||||||
|
public:
|
||||||
|
typedef hash_map<const char*, LLVMSymbol*, hash<const char*>,
|
||||||
|
string_compare> NameToSymbolMap;
|
||||||
|
typedef hash_map<const char*, Module*, hash<const char*>,
|
||||||
|
string_compare> NameToModuleMap;
|
||||||
|
virtual enum LTOStatus readLLVMObjectFile(const std::string &,
|
||||||
|
NameToSymbolMap &,
|
||||||
|
std::set<std::string> &) = 0;
|
||||||
|
virtual enum LTOStatus optimizeModules(const std::string &,
|
||||||
|
std::vector<const char*> &,
|
||||||
|
std::string &) = 0;
|
||||||
|
virtual void getTargetTriple(const std::string &, std::string &) = 0;
|
||||||
|
virtual ~LinkTimeOptimizer() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
/// This is the main link time optimization class. It exposes simple API
|
/// This is the main link time optimization class. It exposes simple API
|
||||||
/// to perform link time optimization using LLVM intermodular optimizer.
|
/// to perform link time optimization using LLVM intermodular optimizer.
|
||||||
class LinkTimeOptimizer {
|
class LTO : public LinkTimeOptimizer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef hash_map<const char*, LLVMSymbol*, hash<const char*>,
|
typedef hash_map<const char*, LLVMSymbol*, hash<const char*>,
|
||||||
|
@ -44,7 +44,7 @@ using namespace llvm;
|
|||||||
extern "C"
|
extern "C"
|
||||||
llvm::LinkTimeOptimizer *createLLVMOptimizer()
|
llvm::LinkTimeOptimizer *createLLVMOptimizer()
|
||||||
{
|
{
|
||||||
llvm::LinkTimeOptimizer *l = new llvm::LinkTimeOptimizer();
|
llvm::LTO *l = new llvm::LTO();
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ findExternalRefs(Value *value, std::set<std::string> &references,
|
|||||||
/// InputFilename is a LLVM bytecode file. If Module with InputFilename is
|
/// InputFilename is a LLVM bytecode file. If Module with InputFilename is
|
||||||
/// available then return it. Otherwise parseInputFilename.
|
/// available then return it. Otherwise parseInputFilename.
|
||||||
Module *
|
Module *
|
||||||
LinkTimeOptimizer::getModule(const std::string &InputFilename)
|
LTO::getModule(const std::string &InputFilename)
|
||||||
{
|
{
|
||||||
Module *m = NULL;
|
Module *m = NULL;
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ LinkTimeOptimizer::getModule(const std::string &InputFilename)
|
|||||||
/// InputFilename is a LLVM bytecode file. Reade this bytecode file and
|
/// InputFilename is a LLVM bytecode file. Reade this bytecode file and
|
||||||
/// set corresponding target triplet string.
|
/// set corresponding target triplet string.
|
||||||
void
|
void
|
||||||
LinkTimeOptimizer::getTargetTriple(const std::string &InputFilename,
|
LTO::getTargetTriple(const std::string &InputFilename,
|
||||||
std::string &targetTriple)
|
std::string &targetTriple)
|
||||||
{
|
{
|
||||||
Module *m = getModule(InputFilename);
|
Module *m = getModule(InputFilename);
|
||||||
@ -135,7 +135,7 @@ LinkTimeOptimizer::getTargetTriple(const std::string &InputFilename,
|
|||||||
/// Collect external references in references vector.
|
/// Collect external references in references vector.
|
||||||
/// Return LTO_READ_SUCCESS if there is no error.
|
/// Return LTO_READ_SUCCESS if there is no error.
|
||||||
enum LTOStatus
|
enum LTOStatus
|
||||||
LinkTimeOptimizer::readLLVMObjectFile(const std::string &InputFilename,
|
LTO::readLLVMObjectFile(const std::string &InputFilename,
|
||||||
NameToSymbolMap &symbols,
|
NameToSymbolMap &symbols,
|
||||||
std::set<std::string> &references)
|
std::set<std::string> &references)
|
||||||
{
|
{
|
||||||
@ -310,7 +310,7 @@ static enum LTOStatus lto_optimize(Module *M, std::ostream &Out,
|
|||||||
/// native object file using OutputFilename
|
/// native object file using OutputFilename
|
||||||
/// Return appropriate LTOStatus.
|
/// Return appropriate LTOStatus.
|
||||||
enum LTOStatus
|
enum LTOStatus
|
||||||
LinkTimeOptimizer::optimizeModules(const std::string &OutputFilename,
|
LTO::optimizeModules(const std::string &OutputFilename,
|
||||||
std::vector<const char *> &exportList,
|
std::vector<const char *> &exportList,
|
||||||
std::string &targetTriple)
|
std::string &targetTriple)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user