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