diff options
| author | Rui Ueyama <ruiu@google.com> | 2015-04-07 22:21:18 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2015-04-07 22:21:18 +0000 |
| commit | 18cd75cc4741f526fb65c0ccd65e2860b0f94014 (patch) | |
| tree | c0f55958087350278d9c3394c345e6fd51860f96 /lld/include | |
| parent | ab745c2ad865c07f3905482fd071ef36c024713a (diff) | |
| download | bcm5719-llvm-18cd75cc4741f526fb65c0ccd65e2860b0f94014.tar.gz bcm5719-llvm-18cd75cc4741f526fb65c0ccd65e2860b0f94014.zip | |
Define SimpleFile::addAtom for concrete atom types.
Previously, addAtom always used dynamic dispatching mechanism to
bin atoms. This patch eliminates dynamic dispatching in most cases.
llvm-svn: 234365
Diffstat (limited to 'lld/include')
| -rw-r--r-- | lld/include/lld/Core/Simple.h | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/lld/include/lld/Core/Simple.h b/lld/include/lld/Core/Simple.h index 2a5a4b105a6..58fc5ea2c90 100644 --- a/lld/include/lld/Core/Simple.h +++ b/lld/include/lld/Core/Simple.h @@ -30,50 +30,55 @@ class SimpleFile : public File { public: SimpleFile(StringRef path) : File(path, kindObject) {} + void addAtom(const DefinedAtom &a) { _defined._atoms.push_back(&a); } + void addAtom(const UndefinedAtom &a) { _undefined._atoms.push_back(&a); } + void addAtom(const SharedLibraryAtom &a) { _shared._atoms.push_back(&a); } + void addAtom(const AbsoluteAtom &a) { _absolute._atoms.push_back(&a); } + void addAtom(const Atom &atom) { - if (auto *defAtom = dyn_cast<DefinedAtom>(&atom)) { - _definedAtoms._atoms.push_back(defAtom); - } else if (auto *undefAtom = dyn_cast<UndefinedAtom>(&atom)) { - _undefinedAtoms._atoms.push_back(undefAtom); - } else if (auto *shlibAtom = dyn_cast<SharedLibraryAtom>(&atom)) { - _sharedLibraryAtoms._atoms.push_back(shlibAtom); - } else if (auto *absAtom = dyn_cast<AbsoluteAtom>(&atom)) { - _absoluteAtoms._atoms.push_back(absAtom); + if (auto *p = dyn_cast<DefinedAtom>(&atom)) { + _defined._atoms.push_back(p); + } else if (auto *p = dyn_cast<UndefinedAtom>(&atom)) { + _undefined._atoms.push_back(p); + } else if (auto *p = dyn_cast<SharedLibraryAtom>(&atom)) { + _shared._atoms.push_back(p); + } else if (auto *p = dyn_cast<AbsoluteAtom>(&atom)) { + _absolute._atoms.push_back(p); } else { llvm_unreachable("atom has unknown definition kind"); } } void removeDefinedAtomsIf(std::function<bool(const DefinedAtom *)> pred) { - auto &atoms = _definedAtoms._atoms; + auto &atoms = _defined._atoms; auto newEnd = std::remove_if(atoms.begin(), atoms.end(), pred); atoms.erase(newEnd, atoms.end()); } const atom_collection<DefinedAtom> &defined() const override { - return _definedAtoms; + return _defined; } const atom_collection<UndefinedAtom> &undefined() const override { - return _undefinedAtoms; + return _undefined; } const atom_collection<SharedLibraryAtom> &sharedLibrary() const override { - return _sharedLibraryAtoms; + return _shared; } const atom_collection<AbsoluteAtom> &absolute() const override { - return _absoluteAtoms; + return _absolute; } typedef range<std::vector<const DefinedAtom *>::iterator> DefinedAtomRange; - DefinedAtomRange definedAtoms() { return make_range(_definedAtoms._atoms); } + DefinedAtomRange definedAtoms() { return make_range(_defined._atoms); } private: - atom_collection_vector<DefinedAtom> _definedAtoms; - atom_collection_vector<UndefinedAtom> _undefinedAtoms; - atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms; - atom_collection_vector<AbsoluteAtom> _absoluteAtoms; + atom_collection_vector<DefinedAtom> _defined; + atom_collection_vector<UndefinedAtom> _undefined; + atom_collection_vector<SharedLibraryAtom> _shared; + atom_collection_vector<AbsoluteAtom> _absolute; }; /// \brief Archive library file that may be used as a virtual container |

