10b57cec5SDimitry Andric //===- llvm/CodeGen/MachineModuleInfoImpls.cpp ----------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file implements object-file format specific implementations of
100b57cec5SDimitry Andric // MachineModuleInfoImpl.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric
140b57cec5SDimitry Andric #include "llvm/CodeGen/MachineModuleInfoImpls.h"
150b57cec5SDimitry Andric #include "llvm/ADT/DenseMap.h"
16*0fca6ea1SDimitry Andric #include "llvm/ADT/STLExtras.h"
170b57cec5SDimitry Andric #include "llvm/MC/MCSymbol.h"
180b57cec5SDimitry Andric
190b57cec5SDimitry Andric using namespace llvm;
200b57cec5SDimitry Andric
210b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
220b57cec5SDimitry Andric // MachineModuleInfoMachO
230b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
240b57cec5SDimitry Andric
250b57cec5SDimitry Andric // Out of line virtual method.
anchor()260b57cec5SDimitry Andric void MachineModuleInfoMachO::anchor() {}
anchor()270b57cec5SDimitry Andric void MachineModuleInfoELF::anchor() {}
anchor()280b57cec5SDimitry Andric void MachineModuleInfoCOFF::anchor() {}
anchor()29fe6060f1SDimitry Andric void MachineModuleInfoWasm::anchor() {}
300b57cec5SDimitry Andric
310b57cec5SDimitry Andric using PairTy = std::pair<MCSymbol *, MachineModuleInfoImpl::StubValueTy>;
SortSymbolPair(const PairTy * LHS,const PairTy * RHS)320b57cec5SDimitry Andric static int SortSymbolPair(const PairTy *LHS, const PairTy *RHS) {
330b57cec5SDimitry Andric return LHS->first->getName().compare(RHS->first->getName());
340b57cec5SDimitry Andric }
350b57cec5SDimitry Andric
getSortedStubs(DenseMap<MCSymbol *,MachineModuleInfoImpl::StubValueTy> & Map)360b57cec5SDimitry Andric MachineModuleInfoImpl::SymbolListTy MachineModuleInfoImpl::getSortedStubs(
370b57cec5SDimitry Andric DenseMap<MCSymbol *, MachineModuleInfoImpl::StubValueTy> &Map) {
380b57cec5SDimitry Andric MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
390b57cec5SDimitry Andric
400b57cec5SDimitry Andric array_pod_sort(List.begin(), List.end(), SortSymbolPair);
410b57cec5SDimitry Andric
420b57cec5SDimitry Andric Map.clear();
430b57cec5SDimitry Andric return List;
440b57cec5SDimitry Andric }
45*0fca6ea1SDimitry Andric
46*0fca6ea1SDimitry Andric using ExprStubPairTy = std::pair<MCSymbol *, const MCExpr *>;
SortAuthStubPair(const ExprStubPairTy * LHS,const ExprStubPairTy * RHS)47*0fca6ea1SDimitry Andric static int SortAuthStubPair(const ExprStubPairTy *LHS,
48*0fca6ea1SDimitry Andric const ExprStubPairTy *RHS) {
49*0fca6ea1SDimitry Andric return LHS->first->getName().compare(RHS->first->getName());
50*0fca6ea1SDimitry Andric }
51*0fca6ea1SDimitry Andric
getSortedExprStubs(DenseMap<MCSymbol *,const MCExpr * > & ExprStubs)52*0fca6ea1SDimitry Andric MachineModuleInfoImpl::ExprStubListTy MachineModuleInfoImpl::getSortedExprStubs(
53*0fca6ea1SDimitry Andric DenseMap<MCSymbol *, const MCExpr *> &ExprStubs) {
54*0fca6ea1SDimitry Andric MachineModuleInfoImpl::ExprStubListTy List(ExprStubs.begin(),
55*0fca6ea1SDimitry Andric ExprStubs.end());
56*0fca6ea1SDimitry Andric
57*0fca6ea1SDimitry Andric array_pod_sort(List.begin(), List.end(), SortAuthStubPair);
58*0fca6ea1SDimitry Andric
59*0fca6ea1SDimitry Andric ExprStubs.clear();
60*0fca6ea1SDimitry Andric return List;
61*0fca6ea1SDimitry Andric }
62