LLVM 22.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/MCContext.h"
12#include "llvm/MC/MCExpr.h"
13#include "llvm/MC/MCSymbol.h"
14#include "llvm/MC/MCValue.h"
15namespace llvm {
16class MCSection;
17}
18
19using namespace llvm;
20
22
23MCContext &MCObjectWriter::getContext() const { return Asm->getContext(); }
24
26 FileNames.clear();
27 AddrsigSyms.clear();
28 EmitAddrsigSection = false;
30 CGProfile.clear();
31}
32
35
37 const MCSymbol &SB,
38 bool InSet) const {
39 assert(!SA.isUndefined() && !SB.isUndefined());
41 /*IsPCRel=*/false);
42}
43
45 const MCSymbol &SymA, const MCFragment &FB, bool InSet,
46 bool IsPCRel) const {
47 const MCSection &SecA = SymA.getSection();
48 const MCSection &SecB = *FB.getParent();
49 // On ELF and COFF A - B is absolute if A and B are in the same section.
50 return &SecA == &SecB;
51}
52
54 FileNames.emplace_back(std::string(FileName), Asm->Symbols.size());
55}
56
58 return Asm->getContext();
59}
60
62 return Asm->getContext().reportError(L, Msg);
63}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define F(x, y, z)
Definition MD5.cpp:55
PowerPC TLS Dynamic Call Fixup
Context object for machine code objects.
Definition MCContext.h:83
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
MCSection * getParent() const
Definition MCSection.h:165
LLVM_ABI MCContext & getContext() const
LLVM_ABI void reportError(SMLoc L, const Twine &Msg) const
bool isSymbolRefDifferenceFullyResolved(const MCSymbol &A, const MCSymbol &B, bool InSet) const
Check whether the difference (A - B) between two symbol references is fully resolved.
SmallVector< CGProfileEntry, 0 > CGProfile
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const
virtual ~MCObjectWriter()
virtual void reset()
lifetime management
virtual void recordRelocation(const MCFragment &F, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)
Record a relocation entry.
std::vector< const MCSymbol * > AddrsigSyms
MCContext & getContext() const
SmallVector< std::pair< std::string, size_t >, 0 > FileNames
List of declared file names.
void addFileName(StringRef FileName)
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:521
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition MCSymbol.h:243
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition MCSymbol.h:251
MCFragment * getFragment() const
Definition MCSymbol.h:346
Represents a location in source code.
Definition SMLoc.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
This is an optimization pass for GlobalISel generic memory operations.