blob: 79c09a94b9fb9de4ba38931ab203580e549c9738 [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 Lattner50f82ef2010-01-20 06:34:14 +000021MCAsmInfo::MCAsmInfo() {
Chris Lattner2dc6ddd2010-01-23 07:21:06 +000022 HasSubsectionsViaSymbols = false;
Chris Lattner87edd272010-01-19 02:09:44 +000023 HasMachoZeroFillDirective = false;
Eric Christopher2d4ea3e2010-05-20 00:49:07 +000024 HasMachoTBSSDirective = false;
Chris Lattner2f2fe052010-01-19 04:34:02 +000025 HasStaticCtorDtorReferenceInStaticMode = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000026 MaxInstLength = 4;
27 PCSymbol = "$";
28 SeparatorChar = ';';
Daniel Dunbarc0070ba2010-02-05 07:32:18 +000029 CommentColumn = 40;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000030 CommentString = "#";
31 GlobalPrefix = "";
32 PrivateGlobalPrefix = ".";
Chris Lattnerc889b3b2009-07-21 17:30:51 +000033 LinkerPrivateGlobalPrefix = "";
Bill Wendlingf8b61372010-06-29 21:24:00 +000034 LinkerWeakGlobalPrefix = "";
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;
Mon P Wang84cd1e72010-04-29 04:00:56 +000040 AllowPeriodsInName = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000041 ZeroDirective = "\t.zero\t";
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000042 AsciiDirective = "\t.ascii\t";
43 AscizDirective = "\t.asciz\t";
44 Data8bitsDirective = "\t.byte\t";
45 Data16bitsDirective = "\t.short\t";
46 Data32bitsDirective = "\t.long\t";
47 Data64bitsDirective = "\t.quad\t";
Chris Lattnera8b97f42009-08-08 20:43:12 +000048 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes0ff6eff2009-08-13 23:30:21 +000049 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000050 AlignDirective = "\t.align\t";
51 AlignmentIsInBytes = true;
52 TextAlignFillValue = 0;
Chris Lattner48b139f2010-01-25 21:10:10 +000053 GPRel32Directive = 0;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000054 GlobalDirective = "\t.globl\t";
Chris Lattner5e969572010-01-26 20:40:54 +000055 HasSetDirective = true;
Chris Lattnerd70deeb2010-01-23 07:47:02 +000056 HasLCOMMDirective = false;
Rafael Espindola8fd77a12010-01-26 20:21:43 +000057 COMMDirectiveAlignmentIsInBytes = true;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000058 HasDotTypeDotSizeDirective = true;
Rafael Espindola5cf2e552008-12-03 11:01:37 +000059 HasSingleParameterDotFile = true;
Chris Lattnerd7b6c9c2010-01-23 05:51:36 +000060 HasNoDeadStrip = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000061 WeakRefDirective = 0;
62 WeakDefDirective = 0;
Chris Lattner048f17b2010-01-19 05:08:13 +000063 LinkOnceDirective = 0;
Chris Lattner10bcc6b2010-01-23 06:53:23 +000064 HiddenVisibilityAttr = MCSA_Hidden;
65 ProtectedVisibilityAttr = MCSA_Protected;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000066 HasLEB128 = false;
67 HasDotLocAndDotFile = false;
68 SupportsDebugInformation = false;
Jim Grosbach29feb6a2009-08-11 00:09:57 +000069 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000070 DwarfRequiresFrameSection = true;
Devang Patel88bf96e2009-04-13 17:02:03 +000071 DwarfUsesInlineInfoSection = false;
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000072 DwarfSectionOffsetDirective = 0;
Chris Lattner0130c1d2010-03-12 21:03:47 +000073 HasMicrosoftFastStdCallMangling = false;
Chris Lattner72d228d2009-08-02 07:24:22 +000074
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000075 AsmTransCBE = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076}
77
Chris Lattner621c44d2009-08-22 20:48:53 +000078MCAsmInfo::~MCAsmInfo() {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079}
80
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081
Chris Lattner621c44d2009-08-22 20:48:53 +000082unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
aslc200b112008-08-16 12:57:46 +000083 unsigned Size = 0;
84 do {
85 Value >>= 7;
86 Size += sizeof(int8_t);
87 } while (Value);
88 return Size;
89}
90
Chris Lattner621c44d2009-08-22 20:48:53 +000091unsigned MCAsmInfo::getSLEB128Size(int Value) {
aslc200b112008-08-16 12:57:46 +000092 unsigned Size = 0;
93 int Sign = Value >> (8 * sizeof(Value) - 1);
94 bool IsMore;
95
96 do {
97 unsigned Byte = Value & 0x7f;
98 Value >>= 7;
99 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
100 Size += sizeof(int8_t);
101 } while (IsMore);
102 return Size;
103}