]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/include/lld/Core/Pass.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / include / lld / Core / Pass.h
1 //===------ Core/Pass.h - Base class for linker passes ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLD_CORE_PASS_H
10 #define LLD_CORE_PASS_H
11
12 #include "llvm/Support/Error.h"
13
14 namespace lld {
15
16 class SimpleFile;
17
18 /// Once the core linking is done (which resolves references, coalesces atoms
19 /// and produces a complete Atom graph), the linker runs a series of passes
20 /// on the Atom graph. The graph is modeled as a File, which means the pass
21 /// has access to all the atoms and to File level attributes. Each pass does
22 /// a particular transformation to the Atom graph or to the File attributes.
23 ///
24 /// This is the abstract base class for all passes.  A Pass does its
25 /// actual work in it perform() method.  It can iterator over Atoms in the
26 /// graph using the *begin()/*end() atom iterator of the File.  It can add
27 /// new Atoms to the graph using the File's addAtom() method.
28 class Pass {
29 public:
30   virtual ~Pass() = default;
31
32   /// Do the actual work of the Pass.
33   virtual llvm::Error perform(SimpleFile &mergedFile) = 0;
34
35 protected:
36   // Only subclassess can be instantiated.
37   Pass() = default;
38 };
39
40 } // end namespace lld
41
42 #endif // LLD_CORE_PASS_H