#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
-#include "llvm/InlineAsm.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/DataTypes.h"
static void destroySentinel(GlobalVariable *GV) { delete GV; }
static iplist<GlobalVariable> &getList(Module *M);
};
-template<> struct ilist_traits<InlineAsm>
-: public SymbolTableListTraits<InlineAsm, Module, Module> {
- // createSentinel is used to create a node that marks the end of the list.
- static InlineAsm *createSentinel();
- static void destroySentinel(InlineAsm *GV) { delete GV; }
- static iplist<InlineAsm> &getList(Module *M);
-};
class Module {
public:
typedef iplist<GlobalVariable> GlobalListType;
typedef iplist<Function> FunctionListType;
- typedef iplist<InlineAsm> InlineAsmListType;
typedef SetVector<std::string> LibraryListType;
// Global Variable iterators.
typedef FunctionListType::iterator iterator;
typedef FunctionListType::const_iterator const_iterator;
- // Inline Asm iterators.
- typedef InlineAsmListType::iterator inlineasm_iterator;
- typedef InlineAsmListType::const_iterator const_inlineasm_iterator;
-
// Library list iterators.
typedef LibraryListType::const_iterator lib_iterator;
private:
GlobalListType GlobalList; // The Global Variables in the module
FunctionListType FunctionList; // The Functions in the module
- InlineAsmListType InlineAsmList; // The inline asm objects in the module.
LibraryListType LibraryList; // The Libraries needed by the module
std::string GlobalScopeAsm; // Inline Asm at global scope.
SymbolTable *SymTab; // Symbol Table for the module
GlobalVariable *getGlobalVariable(const std::string &Name, const Type *Ty,
bool AllowInternal = false);
+ /// getNamedGlobal - Return the first global variable in the module with the
+ /// specified name, of arbitrary type. This method returns null if a global
+ /// with the specified name is not found.
+ ///
+ GlobalVariable *getNamedGlobal(const std::string &Name);
+
//===--------------------------------------------------------------------===//
// Methods for easy access to the types in the module.
GlobalListType &getGlobalList() { return GlobalList; }
const FunctionListType &getFunctionList() const { return FunctionList; }
FunctionListType &getFunctionList() { return FunctionList; }
- const InlineAsmListType &getInlineAsmList() const { return InlineAsmList; }
- InlineAsmListType &getInlineAsmList() { return InlineAsmList; }
/// getSymbolTable() - Get access to the symbol table for the module, where
/// global variables and functions are identified.
size_t size() const { return FunctionList.size(); }
bool empty() const { return FunctionList.empty(); }
- // Inline Asm list interface
- inlineasm_iterator inlineasm_begin() {
- return InlineAsmList.begin();
- }
- const_inlineasm_iterator inlineasm_begin() const {
- return InlineAsmList.begin();
- }
- inlineasm_iterator inlineasm_end() {
- return InlineAsmList.end();
- }
- const_inlineasm_iterator inlineasm_end() const {
- return InlineAsmList.end();
- }
- bool inlineasm_empty() const { return InlineAsmList.empty(); }
-
//===--------------------------------------------------------------------===//
// List of dependent library access functions