xref: /freebsd/contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfoImpls.cpp (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===- llvm/CodeGen/MachineModuleInfoImpls.cpp ----------------------------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric //
9*0b57cec5SDimitry Andric // This file implements object-file format specific implementations of
10*0b57cec5SDimitry Andric // MachineModuleInfoImpl.
11*0b57cec5SDimitry Andric //
12*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
13*0b57cec5SDimitry Andric 
14*0b57cec5SDimitry Andric #include "llvm/CodeGen/MachineModuleInfoImpls.h"
15*0b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h"
16*0b57cec5SDimitry Andric #include "llvm/MC/MCSymbol.h"
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric using namespace llvm;
19*0b57cec5SDimitry Andric 
20*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
21*0b57cec5SDimitry Andric // MachineModuleInfoMachO
22*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
23*0b57cec5SDimitry Andric 
24*0b57cec5SDimitry Andric // Out of line virtual method.
25*0b57cec5SDimitry Andric void MachineModuleInfoMachO::anchor() {}
26*0b57cec5SDimitry Andric void MachineModuleInfoELF::anchor() {}
27*0b57cec5SDimitry Andric void MachineModuleInfoCOFF::anchor() {}
28*0b57cec5SDimitry Andric 
29*0b57cec5SDimitry Andric using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
30*0b57cec5SDimitry Andric static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
31*0b57cec5SDimitry Andric   return LHS->first->getName().compare(RHS->first->getName());
32*0b57cec5SDimitry Andric }
33*0b57cec5SDimitry Andric 
34*0b57cec5SDimitry Andric MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs(
35*0b57cec5SDimitry Andric     DenseMap<MCSymbol *, MachineModuleInfoImpl::StubValueTy> &Map) {
36*0b57cec5SDimitry Andric   MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
37*0b57cec5SDimitry Andric 
38*0b57cec5SDimitry Andric   array_pod_sort(List.begin(), List.end(), SortSymbolPair);
39*0b57cec5SDimitry Andric 
40*0b57cec5SDimitry Andric   Map.clear();
41*0b57cec5SDimitry Andric   return List;
42*0b57cec5SDimitry Andric }
43