blob: 1bba6a3dea056d9c388f06f98937f99a18418608 [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 Korobeynikov3829e8a2008-09-25 21:00:33 +000037 ZeroDirective = "\t.zero\t";
38 ZeroDirectiveSuffix = 0;
39 AsciiDirective = "\t.ascii\t";
40 AscizDirective = "\t.asciz\t";
41 Data8bitsDirective = "\t.byte\t";
42 Data16bitsDirective = "\t.short\t";
43 Data32bitsDirective = "\t.long\t";
44 Data64bitsDirective = "\t.quad\t";
Chris Lattnera8b97f42009-08-08 20:43:12 +000045 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes0ff6eff2009-08-13 23:30:21 +000046 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000047 AlignDirective = "\t.align\t";
48 AlignmentIsInBytes = true;
49 TextAlignFillValue = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000050 JumpTableDirective = 0;
Chris Lattnerdf973042009-08-11 20:30:58 +000051 PICJumpTableDirective = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000052 GlobalDirective = "\t.globl\t";
53 SetDirective = 0;
54 LCOMMDirective = 0;
55 COMMDirective = "\t.comm\t";
56 COMMDirectiveTakesAlignment = true;
57 HasDotTypeDotSizeDirective = true;
Rafael Espindola5cf2e552008-12-03 11:01:37 +000058 HasSingleParameterDotFile = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000059 UsedDirective = 0;
60 WeakRefDirective = 0;
61 WeakDefDirective = 0;
Chris Lattnera5ef4d32009-08-22 21:43:10 +000062 // FIXME: These are ELFish - move to ELFMAI.
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000063 HiddenDirective = "\t.hidden\t";
64 ProtectedDirective = "\t.protected\t";
65 AbsoluteDebugSectionOffsets = false;
66 AbsoluteEHSectionOffsets = false;
67 HasLEB128 = false;
68 HasDotLocAndDotFile = false;
69 SupportsDebugInformation = false;
Jim Grosbach29feb6a2009-08-11 00:09:57 +000070 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000071 DwarfRequiresFrameSection = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000072 DwarfUsesInlineInfoSection = false;
Chris Lattner5c3475e2009-07-17 20:46:40 +000073 Is_EHSymbolPrivate = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000074 GlobalEHDirective = 0;
75 SupportsWeakOmittedEHFrame = true;
76 DwarfSectionOffsetDirective = 0;
Chris Lattner72d228d2009-08-02 07:24:22 +000077
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000078 AsmTransCBE = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079}
80
Chris Lattner621c44d2009-08-22 20:48:53 +000081MCAsmInfo::~MCAsmInfo() {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082}
83
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084
Chris Lattner621c44d2009-08-22 20:48:53 +000085unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
aslc200b112008-08-16 12:57:46 +000086 unsigned Size = 0;
87 do {
88 Value >>= 7;
89 Size += sizeof(int8_t);
90 } while (Value);
91 return Size;
92}
93
Chris Lattner621c44d2009-08-22 20:48:53 +000094unsigned MCAsmInfo::getSLEB128Size(int Value) {
aslc200b112008-08-16 12:57:46 +000095 unsigned Size = 0;
96 int Sign = Value >> (8 * sizeof(Value) - 1);
97 bool IsMore;
98
99 do {
100 unsigned Byte = Value & 0x7f;
101 Value >>= 7;
102 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
103 Size += sizeof(int8_t);
104 } while (IsMore);
105 return Size;
106}