MCAsmInfo.cpp revision bfd1e50c4f51e5f22ba68f28172b0ed9ab66a61a
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  PersonalityPrefix = "";
34  PersonalitySuffix = "";
35  NeedsIndirectEncoding = false;
36  InlineAsmStart = "APP";
37  InlineAsmEnd = "NO_APP";
38  AssemblerDialect = 0;
39  AllowQuotesInName = false;
40  ZeroDirective = "\t.zero\t";
41  ZeroDirectiveSuffix = 0;
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  JumpTableDirective = 0;
54  PICJumpTableDirective = 0;
55  GlobalDirective = "\t.globl\t";
56  SetDirective = 0;
57  LCOMMDirective = 0;
58  COMMDirective = "\t.comm\t";
59  COMMDirectiveTakesAlignment = true;
60  HasDotTypeDotSizeDirective = true;
61  HasSingleParameterDotFile = true;
62  UsedDirective = 0;
63  WeakRefDirective = 0;
64  WeakDefDirective = 0;
65  // FIXME: These are ELFish - move to ELFMAI.
66  HiddenDirective = "\t.hidden\t";
67  ProtectedDirective = "\t.protected\t";
68  AbsoluteDebugSectionOffsets = false;
69  AbsoluteEHSectionOffsets = false;
70  HasLEB128 = false;
71  HasDotLocAndDotFile = false;
72  SupportsDebugInformation = false;
73  ExceptionsType = ExceptionHandling::None;
74  DwarfRequiresFrameSection = true;
75  DwarfUsesInlineInfoSection = false;
76  Is_EHSymbolPrivate = true;
77  GlobalEHDirective = 0;
78  SupportsWeakOmittedEHFrame = true;
79  DwarfSectionOffsetDirective = 0;
80
81  AsmTransCBE = 0;
82}
83
84MCAsmInfo::~MCAsmInfo() {
85}
86
87
88unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
89  unsigned Size = 0;
90  do {
91    Value >>= 7;
92    Size += sizeof(int8_t);
93  } while (Value);
94  return Size;
95}
96
97unsigned MCAsmInfo::getSLEB128Size(int Value) {
98  unsigned Size = 0;
99  int Sign = Value >> (8 * sizeof(Value) - 1);
100  bool IsMore;
101
102  do {
103    unsigned Byte = Value & 0x7f;
104    Value >>= 7;
105    IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
106    Size += sizeof(int8_t);
107  } while (IsMore);
108  return Size;
109}
110