blob: c15d61494ca9e31c2c05fd56e335df4f9bb65cc5 [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"
Chandler Carruth1ec7df12009-10-26 01:35:46 +000016#include "llvm/System/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 Lattnera9182162010-01-19 22:42:28 +000021MCAsmInfo::MCAsmInfo(bool isLittleEndian) {
22 IsLittleEndian = isLittleEndian;
Chris Lattner87edd272010-01-19 02:09:44 +000023 HasMachoZeroFillDirective = false;
Chris Lattner2f2fe052010-01-19 04:34:02 +000024 HasStaticCtorDtorReferenceInStaticMode = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000025 NonexecutableStackDirective = 0;
26 NeedsSet = false;
27 MaxInstLength = 4;
28 PCSymbol = "$";
29 SeparatorChar = ';';
David Greene63486122009-07-13 20:25:48 +000030 CommentColumn = 60;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000031 CommentString = "#";
32 GlobalPrefix = "";
33 PrivateGlobalPrefix = ".";
Chris Lattnerc889b3b2009-07-21 17:30:51 +000034 LinkerPrivateGlobalPrefix = "";
Chris Lattnercae14fd2009-08-11 22:39:40 +000035 InlineAsmStart = "APP";
36 InlineAsmEnd = "NO_APP";
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000037 AssemblerDialect = 0;
Chris Lattner690b02c2009-06-18 23:41:35 +000038 AllowQuotesInName = false;
Anton Korobeynikov3789f872009-09-18 16:57:42 +000039 AllowNameToStartWithDigit = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000040 ZeroDirective = "\t.zero\t";
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000041 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";
Chris Lattnera8b97f42009-08-08 20:43:12 +000047 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes0ff6eff2009-08-13 23:30:21 +000048 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000049 AlignDirective = "\t.align\t";
50 AlignmentIsInBytes = true;
51 TextAlignFillValue = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000052 JumpTableDirective = 0;
Chris Lattnerdf973042009-08-11 20:30:58 +000053 PICJumpTableDirective = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000054 GlobalDirective = "\t.globl\t";
55 SetDirective = 0;
56 LCOMMDirective = 0;
57 COMMDirective = "\t.comm\t";
58 COMMDirectiveTakesAlignment = true;
59 HasDotTypeDotSizeDirective = true;
Rafael Espindola5cf2e552008-12-03 11:01:37 +000060 HasSingleParameterDotFile = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000061 UsedDirective = 0;
62 WeakRefDirective = 0;
63 WeakDefDirective = 0;
Chris Lattner048f17b2010-01-19 05:08:13 +000064 LinkOnceDirective = 0;
Chris Lattnera5ef4d32009-08-22 21:43:10 +000065 // FIXME: These are ELFish - move to ELFMAI.
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000066 HiddenDirective = "\t.hidden\t";
67 ProtectedDirective = "\t.protected\t";
68 AbsoluteDebugSectionOffsets = false;
69 AbsoluteEHSectionOffsets = false;
70 HasLEB128 = false;
71 HasDotLocAndDotFile = false;
72 SupportsDebugInformation = false;
Jim Grosbach29feb6a2009-08-11 00:09:57 +000073 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000074 DwarfRequiresFrameSection = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000075 DwarfUsesInlineInfoSection = false;
Chris Lattner5c3475e2009-07-17 20:46:40 +000076 Is_EHSymbolPrivate = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000077 GlobalEHDirective = 0;
78 SupportsWeakOmittedEHFrame = true;
79 DwarfSectionOffsetDirective = 0;
Chris Lattner72d228d2009-08-02 07:24:22 +000080
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000081 AsmTransCBE = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082}
83
Chris Lattner621c44d2009-08-22 20:48:53 +000084MCAsmInfo::~MCAsmInfo() {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085}
86
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
Chris Lattner621c44d2009-08-22 20:48:53 +000088unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
aslc200b112008-08-16 12:57:46 +000089 unsigned Size = 0;
90 do {
91 Value >>= 7;
92 Size += sizeof(int8_t);
93 } while (Value);
94 return Size;
95}
96
Chris Lattner621c44d2009-08-22 20:48:53 +000097unsigned MCAsmInfo::getSLEB128Size(int Value) {
aslc200b112008-08-16 12:57:46 +000098 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}