LLVM 20.0.0git
MCObjectWriter.cpp
Go to the documentation of this file.
1//===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===//
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
10#include "llvm/MC/MCAssembler.h"
11#include "llvm/MC/MCExpr.h"
12#include "llvm/MC/MCFragment.h"
13#include "llvm/MC/MCSymbol.h"
14namespace llvm {
15class MCSection;
16}
17
18using namespace llvm;
19
21
24 AddrsigSyms.clear();
25 EmitAddrsigSection = false;
27 CGProfile.clear();
28}
29
31 const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B,
32 bool InSet) const {
33 // Modified symbol references cannot be resolved.
34 if (A->getKind() != MCSymbolRefExpr::VK_None ||
35 B->getKind() != MCSymbolRefExpr::VK_None)
36 return false;
37
38 const MCSymbol &SA = A->getSymbol();
39 const MCSymbol &SB = B->getSymbol();
40 assert(!SA.isUndefined() && !SB.isUndefined());
42 InSet, /*IsPCRel=*/false);
43}
44
46 const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
47 bool InSet, bool IsPCRel) const {
48 const MCSection &SecA = SymA.getSection();
49 const MCSection &SecB = *FB.getParent();
50 // On ELF and COFF A - B is absolute if A and B are in the same section.
51 return &SecA == &SecB;
52}
53
55 FileNames.emplace_back(std::string(FileName), Asm.Symbols.size());
56}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSection * getParent() const
Definition: MCFragment.h:99
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const
SmallVector< CGProfileEntry, 0 > CGProfile
virtual ~MCObjectWriter()
virtual void reset()
lifetime management
bool isSymbolRefDifferenceFullyResolved(const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B, bool InSet) const
Check whether the difference (A - B) between two symbol references is fully resolved.
void addFileName(MCAssembler &Asm, StringRef FileName)
std::vector< const MCSymbol * > AddrsigSyms
SmallVector< std::pair< std::string, size_t >, 0 > FileNames
List of declared file names.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:259
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:269
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:397
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:937
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18