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