MCAsmInfo.cpp revision 198892
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  ZeroFillDirective = 0;
23  NonexecutableStackDirective = 0;
24  NeedsSet = false;
25  MaxInstLength = 4;
26  PCSymbol = "$";
27  SeparatorChar = ';';
28  CommentColumn = 60;
29  CommentString = "#";
30  GlobalPrefix = "";
31  PrivateGlobalPrefix = ".";
32  LinkerPrivateGlobalPrefix = "";
33  InlineAsmStart = "APP";
34  InlineAsmEnd = "NO_APP";
35  AssemblerDialect = 0;
36  AllowQuotesInName = false;
37  AllowNameToStartWithDigit = false;
38  ZeroDirective = "\t.zero\t";
39  ZeroDirectiveSuffix = 0;
40  AsciiDirective = "\t.ascii\t";
41  AscizDirective = "\t.asciz\t";
42  Data8bitsDirective = "\t.byte\t";
43  Data16bitsDirective = "\t.short\t";
44  Data32bitsDirective = "\t.long\t";
45  Data64bitsDirective = "\t.quad\t";
46  SunStyleELFSectionSwitchSyntax = false;
47  UsesELFSectionDirectiveForBSS = false;
48  AlignDirective = "\t.align\t";
49  AlignmentIsInBytes = true;
50  TextAlignFillValue = 0;
51  JumpTableDirective = 0;
52  PICJumpTableDirective = 0;
53  GlobalDirective = "\t.globl\t";
54  SetDirective = 0;
55  LCOMMDirective = 0;
56  COMMDirective = "\t.comm\t";
57  COMMDirectiveTakesAlignment = true;
58  HasDotTypeDotSizeDirective = true;
59  HasSingleParameterDotFile = true;
60  UsedDirective = 0;
61  WeakRefDirective = 0;
62  WeakDefDirective = 0;
63  // FIXME: These are ELFish - move to ELFMAI.
64  HiddenDirective = "\t.hidden\t";
65  ProtectedDirective = "\t.protected\t";
66  AbsoluteDebugSectionOffsets = false;
67  AbsoluteEHSectionOffsets = false;
68  HasLEB128 = false;
69  HasDotLocAndDotFile = false;
70  SupportsDebugInformation = false;
71  ExceptionsType = ExceptionHandling::None;
72  DwarfRequiresFrameSection = true;
73  DwarfUsesInlineInfoSection = false;
74  Is_EHSymbolPrivate = true;
75  GlobalEHDirective = 0;
76  SupportsWeakOmittedEHFrame = true;
77  DwarfSectionOffsetDirective = 0;
78
79  AsmTransCBE = 0;
80}
81
82MCAsmInfo::~MCAsmInfo() {
83}
84
85
86unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
87  unsigned Size = 0;
88  do {
89    Value >>= 7;
90    Size += sizeof(int8_t);
91  } while (Value);
92  return Size;
93}
94
95unsigned MCAsmInfo::getSLEB128Size(int Value) {
96  unsigned Size = 0;
97  int Sign = Value >> (8 * sizeof(Value) - 1);
98  bool IsMore;
99
100  do {
101    unsigned Byte = Value & 0x7f;
102    Value >>= 7;
103    IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
104    Size += sizeof(int8_t);
105  } while (IsMore);
106  return Size;
107}
108