LLVM 19.0.0git
Go to the documentation of this file.
1//===- MCAsmInfo.cpp - Asm Info -------------------------------------------===//
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
9// This file defines target asm properties related what form asm statements
10// should take.
14#include "llvm/MC/MCAsmInfo.h"
17#include "llvm/MC/MCContext.h"
18#include "llvm/MC/MCExpr.h"
19#include "llvm/MC/MCStreamer.h"
22using namespace llvm;
24namespace {
28 "dwarf-extended-loc", cl::Hidden,
29 cl::desc("Disable emission of the extended flags in .loc directives."),
30 cl::values(clEnumVal(Default, "Default for platform"),
31 clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")),
34namespace llvm {
36 "use-leb128-directives", cl::Hidden,
38 "Disable the usage of LEB128 directives, and generate .byte instead."),
43 SeparatorString = ";";
44 CommentString = "#";
45 LabelSuffix = ":";
49 InlineAsmStart = "APP";
50 InlineAsmEnd = "NO_APP";
51 Code16Directive = ".code16";
52 Code32Directive = ".code32";
53 Code64Directive = ".code64";
54 ZeroDirective = "\t.zero\t";
55 AsciiDirective = "\t.ascii\t";
56 AscizDirective = "\t.asciz\t";
57 Data8bitsDirective = "\t.byte\t";
58 Data16bitsDirective = "\t.short\t";
59 Data32bitsDirective = "\t.long\t";
60 Data64bitsDirective = "\t.quad\t";
61 GlobalDirective = "\t.globl\t";
62 WeakDirective = "\t.weak\t";
73MCAsmInfo::~MCAsmInfo() = default;
76 InitialFrameState.push_back(Inst);
80 return false;
83const MCExpr *
85 unsigned Encoding,
86 MCStreamer &Streamer) const {
87 return getExprForFDESymbol(Sym, Encoding, Streamer);
90const MCExpr *
92 unsigned Encoding,
93 MCStreamer &Streamer) const {
94 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
95 return MCSymbolRefExpr::create(Sym, Streamer.getContext());
97 MCContext &Context = Streamer.getContext();
99 MCSymbol *PCSym = Context.createTempSymbol();
100 Streamer.emitLabel(PCSym);
101 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
102 return MCBinaryExpr::createSub(Res, PC, Context);
106 if (C == '@')
107 return doesAllowAtInName();
109 return isAlnum(C) || C == '_' || C == '$' || C == '.';
113 if (Name.empty())
114 return false;
116 // If any of the characters in the string is an unacceptable character, force
117 // quotes.
118 for (char C : Name) {
119 if (!isAcceptableChar(C))
120 return false;
121 }
123 return true;
127 // FIXME: Does .section .bss/.data/.text work everywhere??
128 return SectionName == ".text" || SectionName == ".data" ||
#define clEnumVal(ENUMVAL, DESC)
Definition: CommandLine.h:691
Definition: DwarfDebug.cpp:87
@ Default
Definition: DwarfDebug.cpp:87
@ Enable
Definition: DwarfDebug.cpp:87
@ Disable
Definition: DwarfDebug.cpp:87
This file contains constants used for implementing Dwarf debug support.
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:479
static cl::opt< DefaultOnOff > DwarfExtendedLoc("dwarf-extended-loc", cl::Hidden, cl::desc("Disable emission of the extended flags in .loc directives."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
LLVMContext & Context
This file contains some functions that are useful when dealing with strings.
const char * Data16bitsDirective
Definition: MCAsmInfo.h:289
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:75
const char * AsciiDirective
This directive allows emission of an ascii string with the standard C escape characters embedded into...
Definition: MCAsmInfo.h:262
std::vector< MCCFIInstruction > InitialFrameState
Definition: MCAsmInfo.h:504
const char * Code64Directive
Definition: MCAsmInfo.h:190
const char * Code32Directive
Definition: MCAsmInfo.h:189
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
Definition: MCAsmInfo.cpp:79
const char * Data8bitsDirective
These directives are used to output some unit of integer data to the current section.
Definition: MCAsmInfo.h:288
const char * Data64bitsDirective
Definition: MCAsmInfo.h:291
virtual ~MCAsmInfo()
bool doesAllowAtInName() const
Definition: MCAsmInfo.h:683
bool PreserveAsmComments
Preserve Comments in assembly.
Definition: MCAsmInfo.h:525
const char * LabelSuffix
This is appended to emitted labels. Defaults to ":".
Definition: MCAsmInfo.h:154
StringRef PrivateGlobalPrefix
This prefix is used for globals like constant pool entries that are completely private to the ....
Definition: MCAsmInfo.h:168
const char * Data32bitsDirective
Definition: MCAsmInfo.h:290
bool UseIntegratedAssembler
Should we use the integrated assembler? The integrated assembler should be enabled by default (by the...
Definition: MCAsmInfo.h:519
const char * Code16Directive
These are assembly directives that tells the assembler to interpret the following instructions differ...
Definition: MCAsmInfo.h:188
const char * GlobalDirective
This is the directive used to declare a global entity.
Definition: MCAsmInfo.h:342
StringRef PrivateLabelPrefix
This prefix is used for labels for basic blocks.
Definition: MCAsmInfo.h:172
const char * InlineAsmStart
If these are nonempty, they contain a directive to emit before and after an inline assembly statement...
Definition: MCAsmInfo.h:182
bool ParseInlineAsmUsingAsmParser
Use AsmParser to parse inlineAsm when UseIntegratedAssembler is not set.
Definition: MCAsmInfo.h:522
StringRef LinkerPrivateGlobalPrefix
This prefix is used for symbols that should be passed through the assembler but be removed by the lin...
Definition: MCAsmInfo.h:178
virtual const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
Definition: MCAsmInfo.cpp:91
bool PPCUseFullRegisterNames
True if full register names are printed.
Definition: MCAsmInfo.h:244
const char * InlineAsmEnd
Definition: MCAsmInfo.h:183
virtual bool isAcceptableChar(char C) const
Return true if C is an acceptable character inside a symbol name.
Definition: MCAsmInfo.cpp:105
const char * SeparatorString
This string, if specified, is used to separate instructions from each other when on the same line.
Definition: MCAsmInfo.h:131
virtual bool shouldOmitSectionDirective(StringRef SectionName) const
Return true if the .section directive should be omitted when emitting SectionName.
Definition: MCAsmInfo.cpp:126
bool usesELFSectionDirectiveForBSS() const
Definition: MCAsmInfo.h:617
bool SupportsExtendedDwarfLocDirective
True if the target supports flags in ".loc" directive, false if only location is allowed.
Definition: MCAsmInfo.h:500
const char * ZeroDirective
This should be set to the directive used to get some number of zero (and non-zero if supported by the...
Definition: MCAsmInfo.h:252
const char * AscizDirective
If not null, this allows for special handling of zero terminated strings on this target.
Definition: MCAsmInfo.h:267
virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
Definition: MCAsmInfo.cpp:84
bool HasLEB128Directives
True if the target supports LEB128 directives.
Definition: MCAsmInfo.h:241
virtual bool isValidUnquotedName(StringRef Name) const
Return true if the identifier Name does not need quotes to be syntactically correct.
Definition: MCAsmInfo.cpp:112
StringRef CommentString
This indicates the comment string used by the assembler.
Definition: MCAsmInfo.h:135
const char * WeakDirective
Used to declare a global as being a weak symbol. Defaults to ".weak".
Definition: MCAsmInfo.h:413
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:621
Context object for machine code objects.
Definition: MCContext.h:81
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
Streaming machine code generation interface.
Definition: MCStreamer.h:212
MCContext & getContext() const
Definition: MCStreamer.h:297
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:424
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:397
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:718
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:450
@ DW_EH_PE_pcrel
Definition: Dwarf.h:534
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
cl::opt< cl::boolOrDefault > UseLEB128Directives("use-leb128-directives", cl::Hidden, cl::desc("Disable the usage of LEB128 directives, and generate .byte instead."), cl::init(cl::BOU_UNSET))
@ Default
The result values are uniform if and only if all operands are uniform.
@ Enable
Enable colors.