MCAsmInfo.cpp revision 41eb8b47717e1fe1a6d0e99ec1b4e890091f77aa
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  HasMachoZeroFillDirective = false;
23  HasStaticCtorDtorReferenceInStaticMode = false;
24  NonexecutableStackDirective = 0;
25  NeedsSet = false;
26  MaxInstLength = 4;
27  PCSymbol = "$";
28  SeparatorChar = ';';
29  CommentColumn = 60;
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  ZeroDirective = "\t.zero\t";
40  ZeroDirectiveSuffix = 0;
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  JumpTableDirective = 0;
53  PICJumpTableDirective = 0;
54  GlobalDirective = "\t.globl\t";
55  SetDirective = 0;
56  LCOMMDirective = 0;
57  COMMDirective = "\t.comm\t";
58  COMMDirectiveTakesAlignment = true;
59  LCOMMDirectiveTakesAlignment = false;
60  HasDotTypeDotSizeDirective = true;
61  HasSingleParameterDotFile = true;
62  UsedDirective = 0;
63  WeakRefDirective = 0;
64  WeakDefDirective = 0;
65  LinkOnceDirective = 0;
66  // FIXME: These are ELFish - move to ELFMAI.
67  HiddenDirective = "\t.hidden\t";
68  ProtectedDirective = "\t.protected\t";
69  AbsoluteDebugSectionOffsets = false;
70  AbsoluteEHSectionOffsets = false;
71  HasLEB128 = false;
72  HasDotLocAndDotFile = false;
73  SupportsDebugInformation = false;
74  ExceptionsType = ExceptionHandling::None;
75  DwarfRequiresFrameSection = true;
76  DwarfUsesInlineInfoSection = false;
77  Is_EHSymbolPrivate = true;
78  GlobalEHDirective = 0;
79  SupportsWeakOmittedEHFrame = true;
80  DwarfSectionOffsetDirective = 0;
81
82  AsmTransCBE = 0;
83}
84
85MCAsmInfo::~MCAsmInfo() {
86}
87
88
89unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
90  unsigned Size = 0;
91  do {
92    Value >>= 7;
93    Size += sizeof(int8_t);
94  } while (Value);
95  return Size;
96}
97
98unsigned MCAsmInfo::getSLEB128Size(int Value) {
99  unsigned Size = 0;
100  int Sign = Value >> (8 * sizeof(Value) - 1);
101  bool IsMore;
102
103  do {
104    unsigned Byte = Value & 0x7f;
105    Value >>= 7;
106    IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
107    Size += sizeof(int8_t);
108  } while (IsMore);
109  return Size;
110}
111