blob: 74fb930fbc1479f002e643128c69707a8f255f12 [file] [log] [blame]
Chris Lattner621c44d2009-08-22 20:48:53 +00001//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take.
12//
13//===----------------------------------------------------------------------===//
14
Chris Lattner621c44d2009-08-22 20:48:53 +000015#include "llvm/MC/MCAsmInfo.h"
Bill Wendling4f61e502009-08-25 21:09:50 +000016#include "llvm/Support/DataTypes.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017#include <cctype>
18#include <cstring>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
20
Chris Lattner621c44d2009-08-22 20:48:53 +000021MCAsmInfo::MCAsmInfo() {
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000022 ZeroFillDirective = 0;
23 NonexecutableStackDirective = 0;
24 NeedsSet = false;
25 MaxInstLength = 4;
26 PCSymbol = "$";
27 SeparatorChar = ';';
David Greene63486122009-07-13 20:25:48 +000028 CommentColumn = 60;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000029 CommentString = "#";
30 GlobalPrefix = "";
31 PrivateGlobalPrefix = ".";
Chris Lattnerc889b3b2009-07-21 17:30:51 +000032 LinkerPrivateGlobalPrefix = "";
Chris Lattnercae14fd2009-08-11 22:39:40 +000033 InlineAsmStart = "APP";
34 InlineAsmEnd = "NO_APP";
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000035 AssemblerDialect = 0;
Chris Lattner690b02c2009-06-18 23:41:35 +000036 AllowQuotesInName = false;
Anton Korobeynikov3789f872009-09-18 16:57:42 +000037 AllowNameToStartWithDigit = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000038 ZeroDirective = "\t.zero\t";
39 ZeroDirectiveSuffix = 0;
40 AsciiDirective = "\t.ascii\t";
41 AscizDirective = "\t.asciz\t";
42 Data8bitsDirective = "\t.byte\t";
43 Data16bitsDirective = "\t.short\t";
44 Data32bitsDirective = "\t.long\t";
45 Data64bitsDirective = "\t.quad\t";
Chris Lattnera8b97f42009-08-08 20:43:12 +000046 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes0ff6eff2009-08-13 23:30:21 +000047 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000048 AlignDirective = "\t.align\t";
49 AlignmentIsInBytes = true;
50 TextAlignFillValue = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000051 JumpTableDirective = 0;
Chris Lattnerdf973042009-08-11 20:30:58 +000052 PICJumpTableDirective = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000053 GlobalDirective = "\t.globl\t";
54 SetDirective = 0;
55 LCOMMDirective = 0;
56 COMMDirective = "\t.comm\t";
57 COMMDirectiveTakesAlignment = true;
58 HasDotTypeDotSizeDirective = true;
Rafael Espindola5cf2e552008-12-03 11:01:37 +000059 HasSingleParameterDotFile = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000060 UsedDirective = 0;
61 WeakRefDirective = 0;
62 WeakDefDirective = 0;
Chris Lattnera5ef4d32009-08-22 21:43:10 +000063 // FIXME: These are ELFish - move to ELFMAI.
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000064 HiddenDirective = "\t.hidden\t";
65 ProtectedDirective = "\t.protected\t";
66 AbsoluteDebugSectionOffsets = false;
67 AbsoluteEHSectionOffsets = false;
68 HasLEB128 = false;
69 HasDotLocAndDotFile = false;
70 SupportsDebugInformation = false;
Jim Grosbach29feb6a2009-08-11 00:09:57 +000071 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000072 DwarfRequiresFrameSection = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000073 DwarfUsesInlineInfoSection = false;
Chris Lattner5c3475e2009-07-17 20:46:40 +000074 Is_EHSymbolPrivate = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000075 GlobalEHDirective = 0;
76 SupportsWeakOmittedEHFrame = true;
77 DwarfSectionOffsetDirective = 0;
Chris Lattner72d228d2009-08-02 07:24:22 +000078
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000079 AsmTransCBE = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080}
81
Chris Lattner621c44d2009-08-22 20:48:53 +000082MCAsmInfo::~MCAsmInfo() {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083}
84
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085
Chris Lattner621c44d2009-08-22 20:48:53 +000086unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
aslc200b112008-08-16 12:57:46 +000087 unsigned Size = 0;
88 do {
89 Value >>= 7;
90 Size += sizeof(int8_t);
91 } while (Value);
92 return Size;
93}
94
Chris Lattner621c44d2009-08-22 20:48:53 +000095unsigned MCAsmInfo::getSLEB128Size(int Value) {
aslc200b112008-08-16 12:57:46 +000096 unsigned Size = 0;
97 int Sign = Value >> (8 * sizeof(Value) - 1);
98 bool IsMore;
99
100 do {
101 unsigned Byte = Value & 0x7f;
102 Value >>= 7;
103 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
104 Size += sizeof(int8_t);
105 } while (IsMore);
106 return Size;
107}