MCAsmInfo.cpp revision 5c0556341e29246e697c73844a5f9b1e14474715
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/System/DataTypes.h"
17#include <cctype>
18#include <cstring>
19using namespace llvm;
20
21MCAsmInfo::MCAsmInfo() {
22  HasSubsectionsViaSymbols = false;
23  HasMachoZeroFillDirective = false;
24  HasMachoTBSSDirective = false;
25  HasStaticCtorDtorReferenceInStaticMode = false;
26  MaxInstLength = 4;
27  PCSymbol = "$";
28  SeparatorChar = ';';
29  CommentColumn = 40;
30  CommentString = "#";
31  LabelSuffix = ":";
32  GlobalPrefix = "";
33  PrivateGlobalPrefix = ".";
34  LinkerPrivateGlobalPrefix = "";
35  InlineAsmStart = "APP";
36  InlineAsmEnd = "NO_APP";
37  AssemblerDialect = 0;
38  AllowQuotesInName = false;
39  AllowNameToStartWithDigit = false;
40  AllowPeriodsInName = true;
41  ZeroDirective = "\t.zero\t";
42  AsciiDirective = "\t.ascii\t";
43  AscizDirective = "\t.asciz\t";
44  Data8bitsDirective = "\t.byte\t";
45  Data16bitsDirective = "\t.short\t";
46  Data32bitsDirective = "\t.long\t";
47  Data64bitsDirective = "\t.quad\t";
48  SunStyleELFSectionSwitchSyntax = false;
49  UsesELFSectionDirectiveForBSS = false;
50  AlignDirective = "\t.align\t";
51  AlignmentIsInBytes = true;
52  TextAlignFillValue = 0;
53  GPRel32Directive = 0;
54  GlobalDirective = "\t.globl\t";
55  HasSetDirective = true;
56  HasLCOMMDirective = false;
57  COMMDirectiveAlignmentIsInBytes = true;
58  HasDotTypeDotSizeDirective = true;
59  HasSingleParameterDotFile = true;
60  HasNoDeadStrip = false;
61  WeakRefDirective = 0;
62  WeakDefDirective = 0;
63  LinkOnceDirective = 0;
64  HiddenVisibilityAttr = MCSA_Hidden;
65  ProtectedVisibilityAttr = MCSA_Protected;
66  HasLEB128 = false;
67  SupportsDebugInformation = false;
68  ExceptionsType = ExceptionHandling::None;
69  DwarfRequiresFrameSection = true;
70  DwarfUsesInlineInfoSection = false;
71  DwarfUsesAbsoluteLabelForStmtList = true;
72  DwarfSectionOffsetDirective = 0;
73  DwarfUsesLabelOffsetForRanges = true;
74  HasMicrosoftFastStdCallMangling = false;
75
76  AsmTransCBE = 0;
77}
78
79MCAsmInfo::~MCAsmInfo() {
80}
81
82
83unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
84  unsigned Size = 0;
85  do {
86    Value >>= 7;
87    Size += sizeof(int8_t);
88  } while (Value);
89  return Size;
90}
91
92unsigned MCAsmInfo::getSLEB128Size(int Value) {
93  unsigned Size = 0;
94  int Sign = Value >> (8 * sizeof(Value) - 1);
95  bool IsMore;
96
97  do {
98    unsigned Byte = Value & 0x7f;
99    Value >>= 7;
100    IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
101    Size += sizeof(int8_t);
102  } while (IsMore);
103  return Size;
104}
105