MachineModuleInfoImpls.cpp revision 243830
1219820Sjeff//===-- llvm/CodeGen/MachineModuleInfoImpls.cpp ---------------------------===//
2219820Sjeff//
3219820Sjeff//                     The LLVM Compiler Infrastructure
4219820Sjeff//
5219820Sjeff// This file is distributed under the University of Illinois Open Source
6219820Sjeff// License. See LICENSE.TXT for details.
7219820Sjeff//
8219820Sjeff//===----------------------------------------------------------------------===//
9219820Sjeff//
10219820Sjeff// This file implements object-file format specific implementations of
11219820Sjeff// MachineModuleInfoImpl.
12219820Sjeff//
13219820Sjeff//===----------------------------------------------------------------------===//
14219820Sjeff
15219820Sjeff#include "llvm/CodeGen/MachineModuleInfoImpls.h"
16219820Sjeff#include "llvm/MC/MCSymbol.h"
17219820Sjeffusing namespace llvm;
18219820Sjeff
19219820Sjeff//===----------------------------------------------------------------------===//
20219820Sjeff// MachineModuleInfoMachO
21219820Sjeff//===----------------------------------------------------------------------===//
22219820Sjeff
23219820Sjeff// Out of line virtual method.
24219820Sjeffvoid MachineModuleInfoMachO::anchor() {}
25219820Sjeffvoid MachineModuleInfoELF::anchor() {}
26219820Sjeff
27219820Sjeffstatic int SortSymbolPair(const void *LHS, const void *RHS) {
28219820Sjeff  typedef std::pair<MCSymbol*, MachineModuleInfoImpl::StubValueTy> PairTy;
29219820Sjeff  const MCSymbol *LHSS = ((const PairTy *)LHS)->first;
30219820Sjeff  const MCSymbol *RHSS = ((const PairTy *)RHS)->first;
31219820Sjeff  return LHSS->getName().compare(RHSS->getName());
32219820Sjeff}
33219820Sjeff
34219820Sjeff/// GetSortedStubs - Return the entries from a DenseMap in a deterministic
35219820Sjeff/// sorted orer.
36219820SjeffMachineModuleInfoImpl::SymbolListTy
37219820SjeffMachineModuleInfoImpl::GetSortedStubs(const DenseMap<MCSymbol*,
38219820Sjeff                                      MachineModuleInfoImpl::StubValueTy>&Map) {
39219820Sjeff  MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end());
40219820Sjeff
41219820Sjeff  if (!List.empty())
42219820Sjeff    qsort(&List[0], List.size(), sizeof(List[0]), SortSymbolPair);
43219820Sjeff  return List;
44219820Sjeff}
45219820Sjeff
46219820Sjeff