]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/include/lld/Core/Pass.h
Bring lld (release_39 branch, r279477) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / include / lld / Core / Pass.h
1 //===------ Core/Pass.h - Base class for linker passes --------------------===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLD_CORE_PASS_H
11 #define LLD_CORE_PASS_H
12
13 #include "lld/Core/Atom.h"
14 #include "lld/Core/File.h"
15 #include "lld/Core/Reference.h"
16 #include "llvm/Support/Error.h"
17 #include <vector>
18
19 namespace lld {
20 class SimpleFile;
21
22 /// Once the core linking is done (which resolves references, coalesces atoms
23 /// and produces a complete Atom graph), the linker runs a series of passes
24 /// on the Atom graph. The graph is modeled as a File, which means the pass
25 /// has access to all the atoms and to File level attributes. Each pass does
26 /// a particular transformation to the Atom graph or to the File attributes.
27 ///
28 /// This is the abstract base class for all passes.  A Pass does its
29 /// actual work in it perform() method.  It can iterator over Atoms in the
30 /// graph using the *begin()/*end() atom iterator of the File.  It can add
31 /// new Atoms to the graph using the File's addAtom() method.
32 class Pass {
33 public:
34   virtual ~Pass() { }
35
36   /// Do the actual work of the Pass.
37   virtual llvm::Error perform(SimpleFile &mergedFile) = 0;
38
39 protected:
40   // Only subclassess can be instantiated.
41   Pass() { }
42 };
43
44 } // namespace lld
45
46 #endif // LLD_CORE_PASS_H