LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Module.h
Go to the documentation of this file.
1 //===-- llvm/Module.h - C++ class to represent a VM module ------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// @file
11 /// Module.h This file contains the declarations for the Module class.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_MODULE_H
16 #define LLVM_IR_MODULE_H
17 
18 #include "llvm/ADT/OwningPtr.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/GlobalAlias.h"
21 #include "llvm/IR/GlobalVariable.h"
22 #include "llvm/IR/Metadata.h"
24 #include "llvm/Support/DataTypes.h"
25 
26 namespace llvm {
27 
28 class FunctionType;
29 class GVMaterializer;
30 class LLVMContext;
31 class StructType;
32 template<typename T> struct DenseMapInfo;
33 template<typename KeyT, typename ValueT, typename KeyInfoT> class DenseMap;
34 
35 template<> struct ilist_traits<Function>
36  : public SymbolTableListTraits<Function, Module> {
37 
38  // createSentinel is used to get hold of the node that marks the end of the
39  // list... (same trick used here as in ilist_traits<Instruction>)
41  return static_cast<Function*>(&Sentinel);
42  }
43  static void destroySentinel(Function*) {}
44 
46  Function *ensureHead(Function*) const { return createSentinel(); }
47  static void noteHead(Function*, Function*) {}
48 
49 private:
50  mutable ilist_node<Function> Sentinel;
51 };
52 
53 template<> struct ilist_traits<GlobalVariable>
54  : public SymbolTableListTraits<GlobalVariable, Module> {
55  // createSentinel is used to create a node that marks the end of the list.
57  return static_cast<GlobalVariable*>(&Sentinel);
58  }
60 
64 private:
65  mutable ilist_node<GlobalVariable> Sentinel;
66 };
67 
68 template<> struct ilist_traits<GlobalAlias>
69  : public SymbolTableListTraits<GlobalAlias, Module> {
70  // createSentinel is used to create a node that marks the end of the list.
72  return static_cast<GlobalAlias*>(&Sentinel);
73  }
74  static void destroySentinel(GlobalAlias*) {}
75 
78  static void noteHead(GlobalAlias*, GlobalAlias*) {}
79 private:
80  mutable ilist_node<GlobalAlias> Sentinel;
81 };
82 
83 template<> struct ilist_traits<NamedMDNode>
84  : public ilist_default_traits<NamedMDNode> {
85  // createSentinel is used to get hold of a node that marks the end of
86  // the list...
88  return static_cast<NamedMDNode*>(&Sentinel);
89  }
90  static void destroySentinel(NamedMDNode*) {}
91 
94  static void noteHead(NamedMDNode*, NamedMDNode*) {}
97 private:
98  mutable ilist_node<NamedMDNode> Sentinel;
99 };
100 
101 /// A Module instance is used to store all the information related to an
102 /// LLVM module. Modules are the top level container of all other LLVM
103 /// Intermediate Representation (IR) objects. Each module directly contains a
104 /// list of globals variables, a list of functions, a list of libraries (or
105 /// other modules) this module depends on, a symbol table, and various data
106 /// about the target's characteristics.
107 ///
108 /// A module maintains a GlobalValRefMap object that is used to hold all
109 /// constant references to global variables in the module. When a global
110 /// variable is destroyed, it should have no entries in the GlobalValueRefMap.
111 /// @brief The main container class for the LLVM Intermediate Representation.
112 class Module {
113 /// @name Types And Enumerations
114 /// @{
115 public:
116  /// The type for the list of global variables.
118  /// The type for the list of functions.
120  /// The type for the list of aliases.
122  /// The type for the list of named metadata.
124 
125  /// The Global Variable iterator.
127  /// The Global Variable constant iterator.
129 
130  /// The Function iterators.
132  /// The Function constant iterator
134 
135  /// The Global Alias iterators.
137  /// The Global Alias constant iterator
139 
140  /// The named metadata iterators.
142  /// The named metadata constant interators.
144 
145  /// An enumeration for describing the endianess of the target machine.
147 
148  /// An enumeration for describing the size of a pointer on the target machine.
150 
151  /// This enumeration defines the supported behaviors of module flags.
153  /// Emits an error if two values disagree, otherwise the resulting value is
154  /// that of the operands.
155  Error = 1,
156 
157  /// Emits a warning if two values disagree. The result value will be the
158  /// operand for the flag from the first module being linked.
159  Warning = 2,
160 
161  /// Adds a requirement that another module flag be present and have a
162  /// specified value after linking is performed. The value must be a metadata
163  /// pair, where the first element of the pair is the ID of the module flag
164  /// to be restricted, and the second element of the pair is the value the
165  /// module flag should be restricted to. This behavior can be used to
166  /// restrict the allowable results (via triggering of an error) of linking
167  /// IDs with the **Override** behavior.
168  Require = 3,
169 
170  /// Uses the specified value, regardless of the behavior or value of the
171  /// other module. If both modules specify **Override**, but the values
172  /// differ, an error will be emitted.
173  Override = 4,
174 
175  /// Appends the two values, which are required to be metadata nodes.
176  Append = 5,
177 
178  /// Appends the two values, which are required to be metadata
179  /// nodes. However, duplicate entries in the second list are dropped
180  /// during the append operation.
182  };
183 
189  : Behavior(B), Key(K), Val(V) {}
190  };
191 
192 /// @}
193 /// @name Member Variables
194 /// @{
195 private:
196  LLVMContext &Context; ///< The LLVMContext from which types and
197  ///< constants are allocated.
198  GlobalListType GlobalList; ///< The Global Variables in the module
199  FunctionListType FunctionList; ///< The Functions in the module
200  AliasListType AliasList; ///< The Aliases in the module
201  NamedMDListType NamedMDList; ///< The named metadata in the module
202  std::string GlobalScopeAsm; ///< Inline Asm at global scope.
203  ValueSymbolTable *ValSymTab; ///< Symbol table for values
204  OwningPtr<GVMaterializer> Materializer; ///< Used to materialize GlobalValues
205  std::string ModuleID; ///< Human readable identifier for the module
206  std::string TargetTriple; ///< Platform target triple Module compiled on
207  std::string DataLayout; ///< Target data description
208  void *NamedMDSymTab; ///< NamedMDNode names.
209 
210  friend class Constant;
211 
212 /// @}
213 /// @name Constructors
214 /// @{
215 public:
216  /// The Module constructor. Note that there is no default constructor. You
217  /// must provide a name for the module upon construction.
218  explicit Module(StringRef ModuleID, LLVMContext& C);
219  /// The module destructor. This will dropAllReferences.
220  ~Module();
221 
222 /// @}
223 /// @name Module Level Accessors
224 /// @{
225 
226  /// Get the module identifier which is, essentially, the name of the module.
227  /// @returns the module identifier as a string
228  const std::string &getModuleIdentifier() const { return ModuleID; }
229 
230  /// Get the data layout string for the module's target platform. This encodes
231  /// the type sizes and alignments expected by this module.
232  /// @returns the data layout as a string
233  const std::string &getDataLayout() const { return DataLayout; }
234 
235  /// Get the target triple which is a string describing the target host.
236  /// @returns a string containing the target triple.
237  const std::string &getTargetTriple() const { return TargetTriple; }
238 
239  /// Get the target endian information.
240  /// @returns Endianess - an enumeration for the endianess of the target
241  Endianness getEndianness() const;
242 
243  /// Get the target pointer size.
244  /// @returns PointerSize - an enumeration for the size of the target's pointer
245  PointerSize getPointerSize() const;
246 
247  /// Get the global data context.
248  /// @returns LLVMContext - a container for LLVM's global information
249  LLVMContext &getContext() const { return Context; }
250 
251  /// Get any module-scope inline assembly blocks.
252  /// @returns a string containing the module-scope inline assembly blocks.
253  const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; }
254 
255 /// @}
256 /// @name Module Level Mutators
257 /// @{
258 
259  /// Set the module identifier.
260  void setModuleIdentifier(StringRef ID) { ModuleID = ID; }
261 
262  /// Set the data layout
263  void setDataLayout(StringRef DL) { DataLayout = DL; }
264 
265  /// Set the target triple.
266  void setTargetTriple(StringRef T) { TargetTriple = T; }
267 
268  /// Set the module-scope inline assembly blocks.
270  GlobalScopeAsm = Asm;
271  if (!GlobalScopeAsm.empty() &&
272  GlobalScopeAsm[GlobalScopeAsm.size()-1] != '\n')
273  GlobalScopeAsm += '\n';
274  }
275 
276  /// Append to the module-scope inline assembly blocks, automatically inserting
277  /// a separating newline if necessary.
279  GlobalScopeAsm += Asm;
280  if (!GlobalScopeAsm.empty() &&
281  GlobalScopeAsm[GlobalScopeAsm.size()-1] != '\n')
282  GlobalScopeAsm += '\n';
283  }
284 
285 /// @}
286 /// @name Generic Value Accessors
287 /// @{
288 
289  /// getNamedValue - Return the global value in the module with
290  /// the specified name, of arbitrary type. This method returns null
291  /// if a global with the specified name is not found.
293 
294  /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
295  /// This ID is uniqued across modules in the current LLVMContext.
296  unsigned getMDKindID(StringRef Name) const;
297 
298  /// getMDKindNames - Populate client supplied SmallVector with the name for
299  /// custom metadata IDs registered in this LLVMContext.
300  void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
301 
302 
305 
306  /// getTypeByName - Return the type with the specified name, or null if there
307  /// is none by that name.
309 
310 /// @}
311 /// @name Function Accessors
312 /// @{
313 
314  /// getOrInsertFunction - Look up the specified function in the module symbol
315  /// table. Four possibilities:
316  /// 1. If it does not exist, add a prototype for the function and return it.
317  /// 2. If it exists, and has a local linkage, the existing function is
318  /// renamed and a new one is inserted.
319  /// 3. Otherwise, if the existing function has the correct prototype, return
320  /// the existing function.
321  /// 4. Finally, the function exists but has the wrong prototype: return the
322  /// function with a constantexpr cast to the right prototype.
324  AttributeSet AttributeList);
325 
327 
328  /// getOrInsertFunction - Look up the specified function in the module symbol
329  /// table. If it does not exist, add a prototype for the function and return
330  /// it. This function guarantees to return a constant of pointer to the
331  /// specified function type or a ConstantExpr BitCast of that type if the
332  /// named function has a different type. This version of the method takes a
333  /// null terminated list of function arguments, which makes it easier for
334  /// clients to use.
336  AttributeSet AttributeList,
337  Type *RetTy, ...) END_WITH_NULL;
338 
339  /// getOrInsertFunction - Same as above, but without the attributes.
340  Constant *getOrInsertFunction(StringRef Name, Type *RetTy, ...)
341  END_WITH_NULL;
342 
343  /// getFunction - Look up the specified function in the module symbol table.
344  /// If it does not exist, return null.
345  Function *getFunction(StringRef Name) const;
346 
347 /// @}
348 /// @name Global Variable Accessors
349 /// @{
350 
351  /// getGlobalVariable - Look up the specified global variable in the module
352  /// symbol table. If it does not exist, return null. If AllowInternal is set
353  /// to true, this function will return types that have InternalLinkage. By
354  /// default, these types are not returned.
356  bool AllowInternal = false) const {
357  return const_cast<Module *>(this)->getGlobalVariable(Name, AllowInternal);
358  }
359 
360  GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal = false);
361 
362  /// getNamedGlobal - Return the global variable in the module with the
363  /// specified name, of arbitrary type. This method returns null if a global
364  /// with the specified name is not found.
366  return getGlobalVariable(Name, true);
367  }
369  return const_cast<Module *>(this)->getNamedGlobal(Name);
370  }
371 
372  /// getOrInsertGlobal - Look up the specified global in the module symbol
373  /// table.
374  /// 1. If it does not exist, add a declaration of the global and return it.
375  /// 2. Else, the global exists but has the wrong type: return the function
376  /// with a constantexpr cast to the right type.
377  /// 3. Finally, if the existing global is the correct declaration, return
378  /// the existing global.
380 
381 /// @}
382 /// @name Global Alias Accessors
383 /// @{
384 
385  /// getNamedAlias - Return the global alias in the module with the
386  /// specified name, of arbitrary type. This method returns null if a global
387  /// with the specified name is not found.
389 
390 /// @}
391 /// @name Named Metadata Accessors
392 /// @{
393 
394  /// getNamedMetadata - Return the first NamedMDNode in the module with the
395  /// specified name. This method returns null if a NamedMDNode with the
396  /// specified name is not found.
397  NamedMDNode *getNamedMetadata(const Twine &Name) const;
398 
399  /// getOrInsertNamedMetadata - Return the named MDNode in the module
400  /// with the specified name. This method returns a new NamedMDNode if a
401  /// NamedMDNode with the specified name is not found.
403 
404  /// eraseNamedMetadata - Remove the given NamedMDNode from this module
405  /// and delete it.
406  void eraseNamedMetadata(NamedMDNode *NMD);
407 
408 /// @}
409 /// @name Module Flags Accessors
410 /// @{
411 
412  /// getModuleFlagsMetadata - Returns the module flags in the provided vector.
414 
415  /// Return the corresponding value if Key appears in module flags, otherwise
416  /// return null.
417  Value *getModuleFlag(StringRef Key) const;
418 
419  /// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
420  /// represents module-level flags. This method returns null if there are no
421  /// module-level flags.
423 
424  /// getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module
425  /// that represents module-level flags. If module-level flags aren't found,
426  /// it creates the named metadata that contains them.
428 
429  /// addModuleFlag - Add a module-level flag to the module-level flags
430  /// metadata. It will create the module-level flags named metadata if it
431  /// doesn't already exist.
432  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Value *Val);
433  void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
434  void addModuleFlag(MDNode *Node);
435 
436 /// @}
437 /// @name Materialization
438 /// @{
439 
440  /// setMaterializer - Sets the GVMaterializer to GVM. This module must not
441  /// yet have a Materializer. To reset the materializer for a module that
442  /// already has one, call MaterializeAllPermanently first. Destroying this
443  /// module will destroy its materializer without materializing any more
444  /// GlobalValues. Without destroying the Module, there is no way to detach or
445  /// destroy a materializer without materializing all the GVs it controls, to
446  /// avoid leaving orphan unmaterialized GVs.
447  void setMaterializer(GVMaterializer *GVM);
448  /// getMaterializer - Retrieves the GVMaterializer, if any, for this Module.
449  GVMaterializer *getMaterializer() const { return Materializer.get(); }
450 
451  /// isMaterializable - True if the definition of GV has yet to be materialized
452  /// from the GVMaterializer.
453  bool isMaterializable(const GlobalValue *GV) const;
454  /// isDematerializable - Returns true if this GV was loaded from this Module's
455  /// GVMaterializer and the GVMaterializer knows how to dematerialize the GV.
456  bool isDematerializable(const GlobalValue *GV) const;
457 
458  /// Materialize - Make sure the GlobalValue is fully read. If the module is
459  /// corrupt, this returns true and fills in the optional string with
460  /// information about the problem. If successful, this returns false.
461  bool Materialize(GlobalValue *GV, std::string *ErrInfo = 0);
462  /// Dematerialize - If the GlobalValue is read in, and if the GVMaterializer
463  /// supports it, release the memory for the function, and set it up to be
464  /// materialized lazily. If !isDematerializable(), this method is a noop.
465  void Dematerialize(GlobalValue *GV);
466 
467  /// MaterializeAll - Make sure all GlobalValues in this Module are fully read.
468  /// If the module is corrupt, this returns true and fills in the optional
469  /// string with information about the problem. If successful, this returns
470  /// false.
471  bool MaterializeAll(std::string *ErrInfo = 0);
472 
473  /// MaterializeAllPermanently - Make sure all GlobalValues in this Module are
474  /// fully read and clear the Materializer. If the module is corrupt, this
475  /// returns true, fills in the optional string with information about the
476  /// problem, and DOES NOT clear the old Materializer. If successful, this
477  /// returns false.
478  bool MaterializeAllPermanently(std::string *ErrInfo = 0);
479 
480 /// @}
481 /// @name Direct access to the globals list, functions list, and symbol table
482 /// @{
483 
484  /// Get the Module's list of global variables (constant).
485  const GlobalListType &getGlobalList() const { return GlobalList; }
486  /// Get the Module's list of global variables.
487  GlobalListType &getGlobalList() { return GlobalList; }
489  return &Module::GlobalList;
490  }
491  /// Get the Module's list of functions (constant).
492  const FunctionListType &getFunctionList() const { return FunctionList; }
493  /// Get the Module's list of functions.
494  FunctionListType &getFunctionList() { return FunctionList; }
496  return &Module::FunctionList;
497  }
498  /// Get the Module's list of aliases (constant).
499  const AliasListType &getAliasList() const { return AliasList; }
500  /// Get the Module's list of aliases.
501  AliasListType &getAliasList() { return AliasList; }
503  return &Module::AliasList;
504  }
505  /// Get the Module's list of named metadata (constant).
506  const NamedMDListType &getNamedMDList() const { return NamedMDList; }
507  /// Get the Module's list of named metadata.
508  NamedMDListType &getNamedMDList() { return NamedMDList; }
510  return &Module::NamedMDList;
511  }
512  /// Get the symbol table of global variable and function identifiers
513  const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
514  /// Get the Module's symbol table of global variable and function identifiers.
515  ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
516 
517 /// @}
518 /// @name Global Variable Iteration
519 /// @{
520 
521  global_iterator global_begin() { return GlobalList.begin(); }
522  const_global_iterator global_begin() const { return GlobalList.begin(); }
523  global_iterator global_end () { return GlobalList.end(); }
524  const_global_iterator global_end () const { return GlobalList.end(); }
525  bool global_empty() const { return GlobalList.empty(); }
526 
527 /// @}
528 /// @name Function Iteration
529 /// @{
530 
531  iterator begin() { return FunctionList.begin(); }
532  const_iterator begin() const { return FunctionList.begin(); }
533  iterator end () { return FunctionList.end(); }
534  const_iterator end () const { return FunctionList.end(); }
535  size_t size() const { return FunctionList.size(); }
536  bool empty() const { return FunctionList.empty(); }
537 
538 /// @}
539 /// @name Alias Iteration
540 /// @{
541 
542  alias_iterator alias_begin() { return AliasList.begin(); }
543  const_alias_iterator alias_begin() const { return AliasList.begin(); }
544  alias_iterator alias_end () { return AliasList.end(); }
545  const_alias_iterator alias_end () const { return AliasList.end(); }
546  size_t alias_size () const { return AliasList.size(); }
547  bool alias_empty() const { return AliasList.empty(); }
548 
549 
550 /// @}
551 /// @name Named Metadata Iteration
552 /// @{
553 
556  return NamedMDList.begin();
557  }
558 
559  named_metadata_iterator named_metadata_end() { return NamedMDList.end(); }
561  return NamedMDList.end();
562  }
563 
564  size_t named_metadata_size() const { return NamedMDList.size(); }
565  bool named_metadata_empty() const { return NamedMDList.empty(); }
566 
567 
568 /// @}
569 /// @name Utility functions for printing and dumping Module objects
570 /// @{
571 
572  /// Print the module to an output stream with an optional
573  /// AssemblyAnnotationWriter.
574  void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const;
575 
576  /// Dump the module to stderr (for debugging).
577  void dump() const;
578 
579  /// This function causes all the subinstructions to "let go" of all references
580  /// that they are maintaining. This allows one to 'delete' a whole class at
581  /// a time, even though there may be circular references... first all
582  /// references are dropped, and all use counts go to zero. Then everything
583  /// is delete'd for real. Note that no operations are valid on an object
584  /// that has "dropped all references", except operator delete.
585  void dropAllReferences();
586 /// @}
587 };
588 
589 /// An raw_ostream inserter for modules.
590 inline raw_ostream &operator<<(raw_ostream &O, const Module &M) {
591  M.print(O, 0);
592  return O;
593 }
594 
595 // Create wrappers for C Binding types (see CBindingWrapping.h).
597 
598 /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
599  * Module.
600  */
602  return reinterpret_cast<Module*>(MP);
603 }
604 
605 } // End llvm namespace
606 
607 #endif
PointerSize getPointerSize() const
Target Pointer Size information.
Definition: Module.cpp:85
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
Definition: Module.h:513
void setDataLayout(StringRef DL)
Set the data layout.
Definition: Module.h:263
NamedMDNode * createSentinel() const
Definition: Module.h:87
ValueSymbolTable & getValueSymbolTable()
Get the Module's symbol table of global variable and function identifiers.
Definition: Module.h:515
const_alias_iterator alias_begin() const
Definition: Module.h:543
Function * provideInitialHead() const
Definition: Module.h:45
iplist< NamedMDNode >::iterator iterator
Definition: ilist.h:642
The main container class for the LLVM Intermediate Representation.
Definition: Module.h:112
void setModuleIdentifier(StringRef ID)
Set the module identifier.
Definition: Module.h:260
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
Definition: Module.h:485
static void noteHead(Function *, Function *)
Definition: Module.h:47
void setMaterializer(GVMaterializer *GVM)
Definition: Module.cpp:384
named_metadata_iterator named_metadata_end()
Definition: Module.h:559
static void destroySentinel(NamedMDNode *)
Definition: Module.h:90
bool alias_empty() const
Definition: Module.h:547
Endianness
An enumeration for describing the endianess of the target machine.
Definition: Module.h:146
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Definition: Module.cpp:295
static ilist< NamedMDNode > Module::* getSublistAccess(NamedMDNode *)
Definition: Module.h:509
FunctionListType::const_iterator const_iterator
The Function constant iterator.
Definition: Module.h:133
bool empty() const
Definition: Module.h:536
MDNode - a tuple of other values.
Definition: Metadata.h:69
LLVMContext ** unwrap(LLVMContextRef *Tys)
Definition: LLVMContext.h:119
iterator begin()
Definition: ilist.h:359
void addNodeToList(NamedMDNode *)
Definition: Module.h:95
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
Definition: Module.h:499
const std::string & getTargetTriple() const
Definition: Module.h:237
StructType * getTypeByName(StringRef Name) const
Definition: Type.cpp:618
const GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false) const
Definition: Module.h:355
static void destroySentinel(Function *)
Definition: Module.h:43
ModFlagBehavior Behavior
Definition: Module.h:185
Appends the two values, which are required to be metadata nodes.
Definition: Module.h:176
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
Definition: Module.cpp:124
GlobalVariable * createSentinel() const
Definition: Module.h:56
AliasListType::const_iterator const_alias_iterator
The Global Alias constant iterator.
Definition: Module.h:138
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
static iplist< GlobalVariable > Module::* getSublistAccess(GlobalVariable *)
Definition: Module.h:488
void eraseNamedMetadata(NamedMDNode *NMD)
Definition: Module.cpp:308
const GlobalVariable * getNamedGlobal(StringRef Name) const
Definition: Module.h:368
iplist< GlobalAlias > AliasListType
The type for the list of aliases.
Definition: Module.h:121
GVMaterializer * getMaterializer() const
getMaterializer - Retrieves the GVMaterializer, if any, for this Module.
Definition: Module.h:449
ilist< NamedMDNode > NamedMDListType
The type for the list of named metadata.
Definition: Module.h:123
const NamedMDListType & getNamedMDList() const
Get the Module's list of named metadata (constant).
Definition: Module.h:506
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
Definition: Module.h:269
const_alias_iterator alias_end() const
Definition: Module.h:545
ID
LLVM Calling Convention Representation.
Definition: CallingConv.h:26
const std::string & getModuleIdentifier() const
Definition: Module.h:228
#define false
Definition: ConvertUTF.c:64
void removeNodeFromList(NamedMDNode *)
Definition: Module.h:96
bool Materialize(GlobalValue *GV, std::string *ErrInfo=0)
Definition: Module.cpp:403
global_iterator global_begin()
Definition: Module.h:521
struct LLVMOpaqueModuleProvider * LLVMModuleProviderRef
Definition: Core.h:115
NamedMDListType & getNamedMDList()
Get the Module's list of named metadata.
Definition: Module.h:508
#define T
iplist< Function > FunctionListType
The type for the list of functions.
Definition: Module.h:119
bool named_metadata_empty() const
Definition: Module.h:565
void dropAllReferences()
Definition: Module.cpp:450
bool MaterializeAllPermanently(std::string *ErrInfo=0)
Definition: Module.cpp:431
Function * getFunction(StringRef Name) const
Definition: Module.cpp:221
bool global_empty() const
Definition: Module.h:525
const_global_iterator global_end() const
Definition: Module.h:524
Module(StringRef ModuleID, LLVMContext &C)
Definition: Module.cpp:45
const_named_metadata_iterator named_metadata_begin() const
Definition: Module.h:555
always inline
bool MaterializeAll(std::string *ErrInfo=0)
Definition: Module.cpp:420
static iplist< GlobalAlias > Module::* getSublistAccess(GlobalAlias *)
Definition: Module.h:502
GlobalVariable * ensureHead(GlobalVariable *) const
Definition: Module.h:62
alias_iterator alias_end()
Definition: Module.h:544
Function * createSentinel() const
Definition: Module.h:40
bool isDematerializable(const GlobalValue *GV) const
Definition: Module.cpp:397
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Definition: Module.cpp:138
AliasListType & getAliasList()
Get the Module's list of aliases.
Definition: Module.h:501
Constant * getOrInsertGlobal(StringRef Name, Type *Ty)
Definition: Module.cpp:250
GlobalAlias * ensureHead(GlobalAlias *) const
Definition: Module.h:77
size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const
Definition: ilist.h:539
NamedMDNode * getModuleFlagsMetadata() const
Definition: Module.cpp:345
LLVM Constant Representation.
Definition: Constant.h:41
GlobalListType::const_iterator const_global_iterator
The Global Variable constant iterator.
Definition: Module.h:128
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:152
const_iterator begin() const
Definition: Module.h:532
PointerSize
An enumeration for describing the size of a pointer on the target machine.
Definition: Module.h:149
const_global_iterator global_begin() const
Definition: Module.h:522
NamedMDNode * ensureHead(NamedMDNode *) const
Definition: Module.h:93
const_iterator end() const
Definition: Module.h:534
ModuleFlagEntry(ModFlagBehavior B, MDString *K, Value *V)
Definition: Module.h:188
GlobalAlias * createSentinel() const
Definition: Module.h:71
static void noteHead(GlobalVariable *, GlobalVariable *)
Definition: Module.h:63
static void destroySentinel(GlobalVariable *)
Definition: Module.h:59
AliasListType::iterator alias_iterator
The Global Alias iterators.
Definition: Module.h:136
void Dematerialize(GlobalValue *GV)
Definition: Module.cpp:415
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW) const
Definition: AsmWriter.cpp:2132
const std::string & getModuleInlineAsm() const
Definition: Module.h:253
global_iterator global_end()
Definition: Module.h:523
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
Definition: Module.h:492
GlobalListType::iterator global_iterator
The Global Variable iterator.
Definition: Module.h:126
GlobalListType & getGlobalList()
Get the Module's list of global variables.
Definition: Module.h:487
const std::string & getDataLayout() const
Definition: Module.h:233
Function * ensureHead(Function *) const
Definition: Module.h:46
GlobalVariable * getNamedGlobal(StringRef Name)
Definition: Module.h:365
size_t named_metadata_size() const
Definition: Module.h:564
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Definition: ilist.h:385
NamedMDNode * provideInitialHead() const
Definition: Module.h:92
NamedMDNode * getOrInsertModuleFlagsMetadata()
Definition: Module.cpp:352
alias_iterator alias_begin()
Definition: Module.h:542
static void destroySentinel(GlobalAlias *)
Definition: Module.h:74
NamedMDListType::const_iterator const_named_metadata_iterator
The named metadata constant interators.
Definition: Module.h:143
iplist< GlobalVariable > GlobalListType
The type for the list of global variables.
Definition: Module.h:117
size_t size() const
Definition: Module.h:535
GlobalAlias * getNamedAlias(StringRef Name) const
Definition: Module.cpp:279
FunctionListType & getFunctionList()
Get the Module's list of functions.
Definition: Module.h:494
Value * getModuleFlag(StringRef Key) const
Definition: Module.cpp:331
static void noteHead(GlobalAlias *, GlobalAlias *)
Definition: Module.h:78
NamedMDNode * getNamedMetadata(const Twine &Name) const
Definition: Module.cpp:286
static void noteHead(NamedMDNode *, NamedMDNode *)
Definition: Module.h:94
iterator end()
Definition: Module.h:533
Endianness getEndianness() const
Target endian information.
Definition: Module.cpp:64
iterator begin()
Definition: Module.h:531
void appendModuleInlineAsm(StringRef Asm)
Definition: Module.h:278
size_t alias_size() const
Definition: Module.h:546
FunctionListType::iterator iterator
The Function iterators.
Definition: Module.h:131
bool isMaterializable(const GlobalValue *GV) const
Definition: Module.cpp:391
void setTargetTriple(StringRef T)
Set the target triple.
Definition: Module.h:266
~Module()
The module destructor. This will dropAllReferences.
Definition: Module.cpp:52
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1688
struct LLVMOpaqueModule * LLVMModuleRef
Definition: Core.h:80
static NodeTy * createSentinel()
createSentinel - create the dynamic sentinel
Definition: ilist.h:78
GlobalVariable * provideInitialHead() const
Definition: Module.h:61
NamedMDListType::iterator named_metadata_iterator
The named metadata iterators.
Definition: Module.h:141
GlobalAlias * provideInitialHead() const
Definition: Module.h:76
iterator end()
Definition: ilist.h:367
LLVM Value Representation.
Definition: Value.h:66
const_named_metadata_iterator named_metadata_end() const
Definition: Module.h:560
DenseMap< StructType *, unsigned, DenseMapInfo< StructType * > > NumeredTypesMapTy
Definition: Module.h:304
unsigned getMDKindID(StringRef Name) const
Definition: Module.cpp:117
void dump() const
Dump the module to stderr (for debugging).
Definition: AsmWriter.cpp:2218
GlobalValue * getNamedValue(StringRef Name) const
Definition: Module.cpp:111
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Value *Val)
Definition: Module.cpp:359
named_metadata_iterator named_metadata_begin()
Definition: Module.h:554
LLVMContext & getContext() const
Definition: Module.h:249
static iplist< Function > Module::* getSublistAccess(Function *)
Definition: Module.h:495