[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / TextAPI / RecordVisitor.cpp
blobcee04e6447555b008c8565ae723213d0273392cf
1 //===- RecordVisitor.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 /// Implements the TAPI Record Visitor.
10 ///
11 //===----------------------------------------------------------------------===//
13 #include "llvm/TextAPI/RecordVisitor.h"
15 using namespace llvm;
16 using namespace llvm::MachO;
18 RecordVisitor::~RecordVisitor() {}
19 void RecordVisitor::visitObjCInterface(const ObjCInterfaceRecord &) {}
20 void RecordVisitor::visitObjCCategory(const ObjCCategoryRecord &) {}
22 static bool shouldSkipRecord(const Record &R, const bool RecordUndefs) {
23 if (R.isExported())
24 return false;
26 // Skip non exported symbols unless for flat namespace libraries.
27 return !(RecordUndefs && R.isUndefined());
30 void SymbolConverter::visitGlobal(const GlobalRecord &GR) {
31 auto [SymName, SymKind] = parseSymbol(GR.getName(), GR.getFlags());
32 if (shouldSkipRecord(GR, RecordUndefs))
33 return;
34 Symbols->addGlobal(SymKind, SymName, GR.getFlags(), Targ);
37 void SymbolConverter::addIVars(const ArrayRef<ObjCIVarRecord *> IVars,
38 StringRef ContainerName) {
39 for (auto *IV : IVars) {
40 if (shouldSkipRecord(*IV, RecordUndefs))
41 continue;
42 std::string Name =
43 ObjCIVarRecord::createScopedName(ContainerName, IV->getName());
44 Symbols->addGlobal(SymbolKind::ObjectiveCInstanceVariable, Name,
45 IV->getFlags(), Targ);
49 void SymbolConverter::visitObjCInterface(const ObjCInterfaceRecord &ObjCR) {
50 if (!shouldSkipRecord(ObjCR, RecordUndefs)) {
51 Symbols->addGlobal(SymbolKind::ObjectiveCClass, ObjCR.getName(),
52 ObjCR.getFlags(), Targ);
53 if (ObjCR.hasExceptionAttribute())
54 Symbols->addGlobal(SymbolKind::ObjectiveCClassEHType, ObjCR.getName(),
55 ObjCR.getFlags(), Targ);
58 addIVars(ObjCR.getObjCIVars(), ObjCR.getName());
59 for (const auto *Cat : ObjCR.getObjCCategories())
60 addIVars(Cat->getObjCIVars(), ObjCR.getName());
63 void SymbolConverter::visitObjCCategory(const ObjCCategoryRecord &Cat) {
64 addIVars(Cat.getObjCIVars(), Cat.getName());