1 //===------ Core/Pass.h - Base class for linker passes ----------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_CORE_PASS_H
10 #define LLD_CORE_PASS_H
12 #include "llvm/Support/Error.h"
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.
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.
30 virtual ~Pass() = default;
32 /// Do the actual work of the Pass.
33 virtual llvm::Error perform(SimpleFile &mergedFile) = 0;
36 // Only subclassess can be instantiated.
40 } // end namespace lld
42 #endif // LLD_CORE_PASS_H