add a bool for whether .lcomm takes an alignment instead of basing this on "isdarwin".
[oota-llvm.git] / lib / MC / MCAsmInfo.cpp
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>
19 using namespace llvm;
20
21 MCAsmInfo::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   // 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
84 MCAsmInfo::~MCAsmInfo() {
85 }
86
87
88 unsigned 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
97 unsigned 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 }