aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc/GetTapiInterface.cpp
blob: f74db3e7dd85a77aee93c4f8b257b70a061d1146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===--------- GetTapiInterface.cpp - Get interface from TAPI file --------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/ExecutionEngine/Orc/GetTapiInterface.h"

#define DEBUG_TYPE "orc"

namespace llvm::orc {

Expected<SymbolNameSet> getInterfaceFromTapiFile(ExecutionSession &ES,
                                                 object::TapiUniversal &TU) {
  SymbolNameSet Symbols;

  auto CPUType = MachO::getCPUType(ES.getTargetTriple());
  if (!CPUType)
    return CPUType.takeError();

  auto CPUSubType = MachO::getCPUSubType(ES.getTargetTriple());
  if (!CPUSubType)
    return CPUSubType.takeError();

  auto &TUIF = TU.getInterfaceFile();
  auto ArchInterface =
      TUIF.extract(MachO::getArchitectureFromCpuType(*CPUType, *CPUSubType));
  if (!ArchInterface)
    return ArchInterface.takeError();

  for (auto *Sym : (*ArchInterface)->exports())
    Symbols.insert(ES.intern(Sym->getName()));

  return Symbols;
}

} // namespace llvm::orc