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