LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCAsmInfo.cpp
Go to the documentation of this file.
1 //===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines target asm properties related what form asm statements
11 // should take.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCStreamer.h"
19 #include "llvm/Support/DataTypes.h"
20 #include "llvm/Support/Dwarf.h"
21 #include <cctype>
22 #include <cstring>
23 using namespace llvm;
24 
26  PointerSize = 4;
28 
29  IsLittleEndian = true;
30  StackGrowsUp = false;
33  HasMachoTBSSDirective = false;
36  MaxInstLength = 4;
37  MinInstAlignment = 1;
38  DollarIsPC = false;
39  SeparatorString = ";";
40  CommentColumn = 40;
41  CommentString = "#";
42  LabelSuffix = ":";
43  DebugLabelSuffix = ":";
44  GlobalPrefix = "";
45  PrivateGlobalPrefix = ".";
47  InlineAsmStart = "APP";
48  InlineAsmEnd = "NO_APP";
49  Code16Directive = ".code16";
50  Code32Directive = ".code32";
51  Code64Directive = ".code64";
52  AssemblerDialect = 0;
53  AllowAtInName = false;
55  ZeroDirective = "\t.zero\t";
56  AsciiDirective = "\t.ascii\t";
57  AscizDirective = "\t.asciz\t";
58  Data8bitsDirective = "\t.byte\t";
59  Data16bitsDirective = "\t.short\t";
60  Data32bitsDirective = "\t.long\t";
61  Data64bitsDirective = "\t.quad\t";
64  AlignDirective = "\t.align\t";
65  AlignmentIsInBytes = true;
67  GPRel64Directive = 0;
68  GPRel32Directive = 0;
69  GlobalDirective = "\t.globl\t";
70  HasSetDirective = true;
76  HasIdentDirective = false;
77  HasNoDeadStrip = false;
78  WeakRefDirective = 0;
79  WeakDefDirective = 0;
84  HasLEB128 = false;
88  DwarfRegNumForCFI = false;
91 }
92 
94 }
95 
96 
97 unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
98  unsigned Size = 0;
99  do {
100  Value >>= 7;
101  Size += sizeof(int8_t);
102  } while (Value);
103  return Size;
104 }
105 
106 unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
107  unsigned Size = 0;
108  int Sign = Value >> (8 * sizeof(Value) - 1);
109  bool IsMore;
110 
111  do {
112  unsigned Byte = Value & 0x7f;
113  Value >>= 7;
114  IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
115  Size += sizeof(int8_t);
116  } while (IsMore);
117  return Size;
118 }
119 
120 const MCExpr *
122  unsigned Encoding,
123  MCStreamer &Streamer) const {
124  return getExprForFDESymbol(Sym, Encoding, Streamer);
125 }
126 
127 const MCExpr *
129  unsigned Encoding,
130  MCStreamer &Streamer) const {
131  if (!(Encoding & dwarf::DW_EH_PE_pcrel))
132  return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
133 
134  MCContext &Context = Streamer.getContext();
135  const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
136  MCSymbol *PCSym = Context.CreateTempSymbol();
137  Streamer.EmitLabel(PCSym);
138  const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
139  return MCBinaryExpr::CreateSub(Res, PC, Context);
140 }
bool HasSingleParameterDotFile
Definition: MCAsmInfo.h:255
const char * Code16Directive
Definition: MCAsmInfo.h:140
LCOMM::LCOMMType LCOMMDirectiveAlignmentType
Definition: MCAsmInfo.h:247
unsigned TextAlignFillValue
Definition: MCAsmInfo.h:223
bool HasSubsectionsViaSymbols
Definition: MCAsmInfo.h:67
bool DwarfRegNumForCFI
Definition: MCAsmInfo.h:308
const char * GlobalPrefix
Definition: MCAsmInfo.h:120
bool DwarfUsesRelocationsAcrossSections
Definition: MCAsmInfo.h:304
const char * Data64bitsDirective
Definition: MCAsmInfo.h:179
const char * ZeroDirective
Definition: MCAsmInfo.h:162
bool IsLittleEndian
Definition: MCAsmInfo.h:59
const char * GlobalDirective
Definition: MCAsmInfo.h:229
unsigned CalleeSaveStackSlotSize
Definition: MCAsmInfo.h:55
unsigned AssemblerDialect
AssemblerDialect - Which dialect of an assembler variant to use.
Definition: MCAsmInfo.h:145
ExceptionHandling::ExceptionsType ExceptionsType
SupportsExceptionHandling - True if target supports exception handling.
Definition: MCAsmInfo.h:300
bool HasDotTypeDotSizeDirective
Definition: MCAsmInfo.h:251
const char * AlignDirective
Definition: MCAsmInfo.h:213
const char * AsciiDirective
Definition: MCAsmInfo.h:166
bool AlignmentIsInBytes
Definition: MCAsmInfo.h:219
const char * PrivateGlobalPrefix
Definition: MCAsmInfo.h:125
const char * SeparatorString
Definition: MCAsmInfo.h:102
bool HasNoDeadStrip
Definition: MCAsmInfo.h:263
virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
Definition: MCAsmInfo.cpp:121
bool UsesELFSectionDirectiveForBSS
Definition: MCAsmInfo.h:199
static unsigned getSLEB128Size(int64_t Value)
Definition: MCAsmInfo.cpp:106
const char * Data8bitsDirective
Definition: MCAsmInfo.h:176
bool HasAggressiveSymbolFolding
Definition: MCAsmInfo.h:239
bool StackGrowsUp
Definition: MCAsmInfo.h:63
MCContext & getContext() const
Definition: MCStreamer.h:168
static const MCBinaryExpr * CreateSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:460
bool HasMicrosoftFastStdCallMangling
Definition: MCAsmInfo.h:204
bool SunStyleELFSectionSwitchSyntax
Definition: MCAsmInfo.h:194
MCSymbolAttr HiddenVisibilityAttr
Definition: MCAsmInfo.h:279
const char * Code32Directive
Definition: MCAsmInfo.h:141
const char * CommentString
Definition: MCAsmInfo.h:110
.protected (ELF)
Definition: MCDirectives.h:39
const char * AscizDirective
Definition: MCAsmInfo.h:171
static const MCSymbolRefExpr * Create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:270
const char * InlineAsmStart
Definition: MCAsmInfo.h:134
.hidden (ELF)
Definition: MCDirectives.h:31
bool HasIdentDirective
Definition: MCAsmInfo.h:259
const char * GPRel64Directive
Definition: MCAsmInfo.h:184
const char * DebugLabelSuffix
LabelSuffix - This is appended to emitted labels.
Definition: MCAsmInfo.h:116
bool HasSetDirective
HasSetDirective - True if the assembler supports the .set directive.
Definition: MCAsmInfo.h:232
bool COMMDirectiveAlignmentIsInBytes
Definition: MCAsmInfo.h:243
unsigned PointerSize
Definition: MCAsmInfo.h:50
bool AllowAtInName
This is true if the assembler allows @ characters in symbol names. Defaults to false.
Definition: MCAsmInfo.h:149
bool SupportsDebugInformation
Definition: MCAsmInfo.h:297
const char * WeakRefDirective
Definition: MCAsmInfo.h:267
const char * WeakDefDirective
Definition: MCAsmInfo.h:271
const char * Data16bitsDirective
Definition: MCAsmInfo.h:177
bool LinkerRequiresNonEmptyDwarfLines
Definition: MCAsmInfo.h:86
bool HasLEB128
HasLEB128 - True if target asm supports leb128 directives.
Definition: MCAsmInfo.h:293
virtual void EmitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:212
const char * LabelSuffix
LabelSuffix - This is appended to emitted labels.
Definition: MCAsmInfo.h:113
bool HasMachoZeroFillDirective
Definition: MCAsmInfo.h:71
bool HasStaticCtorDtorReferenceInStaticMode
Definition: MCAsmInfo.h:81
virtual ~MCAsmInfo()
Definition: MCAsmInfo.cpp:93
const char * InlineAsmEnd
Definition: MCAsmInfo.h:135
bool HasMachoTBSSDirective
Definition: MCAsmInfo.h:75
unsigned MinInstAlignment
Definition: MCAsmInfo.h:94
const char * Data32bitsDirective
Definition: MCAsmInfo.h:178
const char * GPRel32Directive
Definition: MCAsmInfo.h:189
unsigned CommentColumn
Definition: MCAsmInfo.h:106
MCSymbolAttr ProtectedVisibilityAttr
Definition: MCAsmInfo.h:288
bool UseDataRegionDirectives
Definition: MCAsmInfo.h:154
bool NeedsDwarfSectionOffsetDirective
Definition: MCAsmInfo.h:206
const char * LinkOnceDirective
Definition: MCAsmInfo.h:275
MCSymbolAttr HiddenDeclarationVisibilityAttr
Definition: MCAsmInfo.h:283
const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
Definition: MCAsmInfo.cpp:128
static unsigned getULEB128Size(uint64_t Value)
Definition: MCAsmInfo.cpp:97
LLVM Value Representation.
Definition: Value.h:66
const char * LinkerPrivateGlobalPrefix
Definition: MCAsmInfo.h:130
const char * Code64Directive
Definition: MCAsmInfo.h:142
unsigned MaxInstLength
Definition: MCAsmInfo.h:90