mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 22:34:39 +00:00
Add support for the link-time pass list to Modules.
llvm-svn: 16321
This commit is contained in:
parent
d9bd9a2d8e
commit
4a1593ebd2
@ -49,6 +49,7 @@ public:
|
|||||||
typedef iplist<GlobalVariable> GlobalListType;
|
typedef iplist<GlobalVariable> GlobalListType;
|
||||||
typedef iplist<Function> FunctionListType;
|
typedef iplist<Function> FunctionListType;
|
||||||
typedef SetVector<std::string> LibraryListType;
|
typedef SetVector<std::string> LibraryListType;
|
||||||
|
typedef std::vector<std::string> PassListType;
|
||||||
|
|
||||||
// Global Variable iterators...
|
// Global Variable iterators...
|
||||||
typedef GlobalListType::iterator giterator;
|
typedef GlobalListType::iterator giterator;
|
||||||
@ -65,6 +66,9 @@ public:
|
|||||||
// Library list iterators
|
// Library list iterators
|
||||||
typedef LibraryListType::const_iterator lib_iterator;
|
typedef LibraryListType::const_iterator lib_iterator;
|
||||||
|
|
||||||
|
// Link-time Pass list iterators
|
||||||
|
typedef PassListType::const_iterator pass_iterator;
|
||||||
|
|
||||||
enum Endianness { AnyEndianness, LittleEndian, BigEndian };
|
enum Endianness { AnyEndianness, LittleEndian, BigEndian };
|
||||||
enum PointerSize { AnyPointerSize, Pointer32, Pointer64 };
|
enum PointerSize { AnyPointerSize, Pointer32, Pointer64 };
|
||||||
|
|
||||||
@ -72,6 +76,7 @@ private:
|
|||||||
GlobalListType GlobalList; // The Global Variables in the module
|
GlobalListType GlobalList; // The Global Variables in the module
|
||||||
FunctionListType FunctionList; // The Functions in the module
|
FunctionListType FunctionList; // The Functions in the module
|
||||||
LibraryListType LibraryList; // The Libraries needed by the module
|
LibraryListType LibraryList; // The Libraries needed by the module
|
||||||
|
PassListType PassList; // The Passes needed by the module at link time
|
||||||
SymbolTable *SymTab; // Symbol Table for the module
|
SymbolTable *SymTab; // Symbol Table for the module
|
||||||
std::string ModuleID; // Human readable identifier for the module
|
std::string ModuleID; // Human readable identifier for the module
|
||||||
std::string TargetTriple; // Platform target triple Module compiled on
|
std::string TargetTriple; // Platform target triple Module compiled on
|
||||||
@ -227,7 +232,7 @@ public:
|
|||||||
inline Function &back() { return FunctionList.back(); }
|
inline Function &back() { return FunctionList.back(); }
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// List of dependent library access functionsns
|
// List of dependent library access functions
|
||||||
|
|
||||||
/// @brief Get a constant iterator to beginning of dependent library list.
|
/// @brief Get a constant iterator to beginning of dependent library list.
|
||||||
inline lib_iterator lib_begin() const { return LibraryList.begin(); }
|
inline lib_iterator lib_begin() const { return LibraryList.begin(); }
|
||||||
@ -247,6 +252,30 @@ public:
|
|||||||
/// @brief Get all the libraries
|
/// @brief Get all the libraries
|
||||||
inline const LibraryListType& getLibraries() const { return LibraryList; }
|
inline const LibraryListType& getLibraries() const { return LibraryList; }
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Access functions for Link-time pass list
|
||||||
|
|
||||||
|
/// @brief Get a constant iterator to beginning of pass list.
|
||||||
|
inline pass_iterator pass_begin() const { return PassList.begin(); }
|
||||||
|
|
||||||
|
/// @brief Get a constant iterator to end of pass list.
|
||||||
|
inline pass_iterator pass_end() const { return PassList.end(); }
|
||||||
|
|
||||||
|
/// @brief Returns the number of items in the list of passes.
|
||||||
|
inline unsigned pass_size() const { return PassList.size(); }
|
||||||
|
|
||||||
|
/// @brief Add a library to the list of passes
|
||||||
|
inline void addPass(const std::string& Pass){ PassList.push_back(Pass); }
|
||||||
|
|
||||||
|
/// @brief Remove a library from the list of passes
|
||||||
|
void removePass(const std::string& Lib);
|
||||||
|
|
||||||
|
/// @brief Get all the passes
|
||||||
|
inline const PassListType& getPasses() const { return PassList; }
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Utility functions for printing and dumping Module objects
|
||||||
|
|
||||||
void print(std::ostream &OS) const { print(OS, 0); }
|
void print(std::ostream &OS) const { print(OS, 0); }
|
||||||
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
|
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ not { return NOT; } /* Deprecated, turned into XOR */
|
|||||||
target { return TARGET; }
|
target { return TARGET; }
|
||||||
triple { return TRIPLE; }
|
triple { return TRIPLE; }
|
||||||
deplibs { return DEPLIBS; }
|
deplibs { return DEPLIBS; }
|
||||||
|
passes { return PASSES; }
|
||||||
endian { return ENDIAN; }
|
endian { return ENDIAN; }
|
||||||
pointersize { return POINTERSIZE; }
|
pointersize { return POINTERSIZE; }
|
||||||
little { return LITTLE; }
|
little { return LITTLE; }
|
||||||
|
@ -910,7 +910,7 @@ Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
|
|||||||
%token DECLARE GLOBAL CONSTANT VOLATILE
|
%token DECLARE GLOBAL CONSTANT VOLATILE
|
||||||
%token TO DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE WEAK APPENDING
|
%token TO DOTDOTDOT NULL_TOK CONST INTERNAL LINKONCE WEAK APPENDING
|
||||||
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
|
||||||
%token DEPLIBS
|
%token DEPLIBS PASSES
|
||||||
|
|
||||||
// Basic Block Terminating Operators
|
// Basic Block Terminating Operators
|
||||||
%token <TermOpVal> RET BR SWITCH INVOKE UNWIND
|
%token <TermOpVal> RET BR SWITCH INVOKE UNWIND
|
||||||
@ -1484,6 +1484,8 @@ ConstPool : ConstPool OptAssign TYPE TypesV { // Types can be defined in the co
|
|||||||
}
|
}
|
||||||
| ConstPool DEPLIBS '=' LibrariesDefinition {
|
| ConstPool DEPLIBS '=' LibrariesDefinition {
|
||||||
}
|
}
|
||||||
|
| ConstPool PASSES '=' PassesDefinition {
|
||||||
|
}
|
||||||
| /* empty: end of list */ {
|
| /* empty: end of list */ {
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1522,6 +1524,19 @@ LibList : LibList ',' STRINGCONSTANT {
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
PassesDefinition : '[' PassList ']';
|
||||||
|
PassList : PassList ',' STRINGCONSTANT {
|
||||||
|
CurModule.CurrentModule->addLibrary($3);
|
||||||
|
free($3);
|
||||||
|
}
|
||||||
|
| STRINGCONSTANT {
|
||||||
|
CurModule.CurrentModule->addLibrary($1);
|
||||||
|
free($1);
|
||||||
|
}
|
||||||
|
| /* empty: end of list */ {
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Rules to match Function Headers
|
// Rules to match Function Headers
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -777,6 +777,20 @@ void AssemblyWriter::printModule(const Module *M) {
|
|||||||
}
|
}
|
||||||
Out << " ]\n";
|
Out << " ]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop over the link time pass list and emit them
|
||||||
|
Module::pass_iterator PI = M->pass_begin();
|
||||||
|
Module::pass_iterator PE = M->pass_end();
|
||||||
|
if (LI != LE) {
|
||||||
|
Out << "passes = [\n";
|
||||||
|
while (LI != LE) {
|
||||||
|
Out << "\"" << *LI << "\"";
|
||||||
|
++LI;
|
||||||
|
if (LI != LE)
|
||||||
|
Out << ",\n";
|
||||||
|
}
|
||||||
|
Out << " ]\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Loop over the symbol table, emitting all named constants...
|
// Loop over the symbol table, emitting all named constants...
|
||||||
printSymbolTable(M->getSymbolTable());
|
printSymbolTable(M->getSymbolTable());
|
||||||
|
@ -270,6 +270,12 @@ std::string Module::getTypeName(const Type *Ty) const {
|
|||||||
return ""; // Must not have found anything...
|
return ""; // Must not have found anything...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::removePass(const std::string& Lib) {
|
||||||
|
PassListType::iterator I = find(PassList.begin(),PassList.end(),Lib);
|
||||||
|
if (I != PassList.end())
|
||||||
|
PassList.erase(I);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Other module related stuff.
|
// Other module related stuff.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user