xref: /freebsd/contrib/llvm-project/llvm/lib/CodeGen/MachineModuleInfoImpls.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===- llvm/CodeGen/MachineModuleInfoImpls.cpp ----------------------------===//
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 // This file implements object-file format specific implementations of
10 // MachineModuleInfoImpl.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/MC/MCSymbol.h"
18 
19 using namespace llvm;
20 
21 //===----------------------------------------------------------------------===//
22 // MachineModuleInfoMachO
23 //===----------------------------------------------------------------------===//
24 
25 // Out of line virtual method.
anchor()26 void MachineModuleInfoMachO::anchor() {}
anchor()27 void MachineModuleInfoELF::anchor() {}
anchor()28 void MachineModuleInfoCOFF::anchor() {}
anchor()29 void MachineModuleInfoWasm::anchor() {}
30 
31 using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
SortSymbolPair(const PairTy * LHS,const PairTy * RHS)32 static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
33   return LHS->first->getName().compare(RHS->first->getName());
34 }
35 
getSortedStubs(DenseMap<MCSymbol *,MachineModuleInfoImpl::StubValueTy> & Map)36 MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs(
37     DenseMap<MCSymbol *, MachineModuleInfoImpl::StubValueTy> &Map) {
38   MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
39 
40   array_pod_sort(List.begin(), List.end(), SortSymbolPair);
41 
42   Map.clear();
43   return List;
44 }
45 
46 using ExprStubPairTy = std::pair<MCSymbol *, const MCExpr *>;
SortAuthStubPair(const ExprStubPairTy * LHS,const ExprStubPairTy * RHS)47 static int SortAuthStubPair(const ExprStubPairTy *LHS,
48                             const ExprStubPairTy *RHS) {
49   return LHS->first->getName().compare(RHS->first->getName());
50 }
51 
getSortedExprStubs(DenseMap<MCSymbol *,const MCExpr * > & ExprStubs)52 MachineModuleInfoImpl::ExprStubListTy MachineModuleInfoImpl::getSortedExprStubs(
53     DenseMap<MCSymbol *, const MCExpr *> &ExprStubs) {
54   MachineModuleInfoImpl::ExprStubListTy List(ExprStubs.begin(),
55                                              ExprStubs.end());
56 
57   array_pod_sort(List.begin(), List.end(), SortAuthStubPair);
58 
59   ExprStubs.clear();
60   return List;
61 }
62