MCAsmInfo.cpp revision f59cac5ed36360b4c462781051f996b3499d7e0f
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  GlobalPrefix = "";
32  PrivateGlobalPrefix = ".";
33  LinkerPrivateGlobalPrefix = "";
34  InlineAsmStart = "APP";
35  InlineAsmEnd = "NO_APP";
36  AssemblerDialect = 0;
37  AllowQuotesInName = false;
38  AllowNameToStartWithDigit = false;
39  AllowPeriodsInName = true;
40  ZeroDirective = "\t.zero\t";
41  AsciiDirective = "\t.ascii\t";
42  AscizDirective = "\t.asciz\t";
43  Data8bitsDirective = "\t.byte\t";
44  Data16bitsDirective = "\t.short\t";
45  Data32bitsDirective = "\t.long\t";
46  Data64bitsDirective = "\t.quad\t";
47  SunStyleELFSectionSwitchSyntax = false;
48  UsesELFSectionDirectiveForBSS = false;
49  AlignDirective = "\t.align\t";
50  AlignmentIsInBytes = true;
51  TextAlignFillValue = 0;
52  GPRel32Directive = 0;
53  GlobalDirective = "\t.globl\t";
54  HasSetDirective = true;
55  HasLCOMMDirective = false;
56  COMMDirectiveAlignmentIsInBytes = true;
57  HasDotTypeDotSizeDirective = true;
58  HasSingleParameterDotFile = true;
59  HasNoDeadStrip = false;
60  WeakRefDirective = 0;
61  WeakDefDirective = 0;
62  WeakDefAutoPrivateDirective = 0;
63  LinkOnceDirective = 0;
64  HiddenVisibilityAttr = MCSA_Hidden;
65  ProtectedVisibilityAttr = MCSA_Protected;
66  HasLEB128 = false;
67  HasDotLocAndDotFile = false;
68  SupportsDebugInformation = false;
69  ExceptionsType = ExceptionHandling::None;
70  DwarfRequiresFrameSection = true;
71  DwarfUsesInlineInfoSection = false;
72  DwarfSectionOffsetDirective = 0;
73  HasMicrosoftFastStdCallMangling = false;
74
75  AsmTransCBE = 0;
76}
77
78MCAsmInfo::~MCAsmInfo() {
79}
80
81
82unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
83  unsigned Size = 0;
84  do {
85    Value >>= 7;
86    Size += sizeof(int8_t);
87  } while (Value);
88  return Size;
89}
90
91unsigned MCAsmInfo::getSLEB128Size(int Value) {
92  unsigned Size = 0;
93  int Sign = Value >> (8 * sizeof(Value) - 1);
94  bool IsMore;
95
96  do {
97    unsigned Byte = Value & 0x7f;
98    Value >>= 7;
99    IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
100    Size += sizeof(int8_t);
101  } while (IsMore);
102  return Size;
103}
104