blob: 1bc63d03fba7107d176e24d5f0d7019c19d99dd2 [file] [log] [blame]
Chris Lattner7b26fce2009-08-22 20:48:53 +00001//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
Jim Laskey681ecbb2006-09-06 18:35:33 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey681ecbb2006-09-06 18:35:33 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take.
12//
13//===----------------------------------------------------------------------===//
14
Chris Lattner7b26fce2009-08-22 20:48:53 +000015#include "llvm/MC/MCAsmInfo.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000016#include "llvm/Support/DataTypes.h"
Dale Johannesen0a1069d2007-04-23 20:00:17 +000017#include <cctype>
18#include <cstring>
Jim Laskey681ecbb2006-09-06 18:35:33 +000019using namespace llvm;
20
Chris Lattner2b4364f2010-01-20 06:34:14 +000021MCAsmInfo::MCAsmInfo() {
Chris Lattner76bdea32010-01-23 07:21:06 +000022 HasSubsectionsViaSymbols = false;
Chris Lattner1d371882010-01-19 02:09:44 +000023 HasMachoZeroFillDirective = false;
Eric Christopher27e7ffc2010-05-20 00:49:07 +000024 HasMachoTBSSDirective = false;
Chris Lattnere9d28b12010-01-19 04:34:02 +000025 HasStaticCtorDtorReferenceInStaticMode = false;
Rafael Espindola1048e752010-12-04 00:31:13 +000026 LinkerRequiresNonEmptyDwarfLines = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000027 MaxInstLength = 4;
28 PCSymbol = "$";
29 SeparatorChar = ';';
Daniel Dunbar675ae272010-02-05 07:32:18 +000030 CommentColumn = 40;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000031 CommentString = "#";
Chris Lattner7bce0592010-09-22 22:19:53 +000032 LabelSuffix = ":";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000033 GlobalPrefix = "";
34 PrivateGlobalPrefix = ".";
Chris Lattner1177cee2009-07-21 17:30:51 +000035 LinkerPrivateGlobalPrefix = "";
Chris Lattnerabdcbc72009-08-11 22:39:40 +000036 InlineAsmStart = "APP";
37 InlineAsmEnd = "NO_APP";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000038 AssemblerDialect = 0;
Chris Lattnerb8476452009-06-18 23:41:35 +000039 AllowQuotesInName = false;
Anton Korobeynikov592638a2009-09-18 16:57:42 +000040 AllowNameToStartWithDigit = false;
Mon P Wangb0a0a262010-04-29 04:00:56 +000041 AllowPeriodsInName = true;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000042 ZeroDirective = "\t.zero\t";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000043 AsciiDirective = "\t.ascii\t";
44 AscizDirective = "\t.asciz\t";
45 Data8bitsDirective = "\t.byte\t";
46 Data16bitsDirective = "\t.short\t";
47 Data32bitsDirective = "\t.long\t";
48 Data64bitsDirective = "\t.quad\t";
Chris Lattnerc9ea8fd2009-08-08 20:43:12 +000049 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes62e6a8b2009-08-13 23:30:21 +000050 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000051 AlignDirective = "\t.align\t";
52 AlignmentIsInBytes = true;
53 TextAlignFillValue = 0;
Chris Lattner19bd0392010-01-25 21:10:10 +000054 GPRel32Directive = 0;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000055 GlobalDirective = "\t.globl\t";
Chris Lattnerff234e02010-01-26 20:40:54 +000056 HasSetDirective = true;
Rafael Espindola1c8ac8f2010-12-04 03:21:47 +000057 NeedsSetToChangeDiffSize = false;
Chris Lattnerb1301f72010-01-23 07:47:02 +000058 HasLCOMMDirective = false;
Rafael Espindoladcb03f02010-01-26 20:21:43 +000059 COMMDirectiveAlignmentIsInBytes = true;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000060 HasDotTypeDotSizeDirective = true;
Rafael Espindolacda011b2008-12-03 11:01:37 +000061 HasSingleParameterDotFile = true;
Chris Lattner1deb09c2010-01-23 05:51:36 +000062 HasNoDeadStrip = false;
Kevin Enderby8be14412010-11-19 18:39:33 +000063 HasSymbolResolver = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000064 WeakRefDirective = 0;
65 WeakDefDirective = 0;
Chris Lattnerb1f29342010-01-19 05:08:13 +000066 LinkOnceDirective = 0;
Chris Lattner0bfd2792010-01-23 06:53:23 +000067 HiddenVisibilityAttr = MCSA_Hidden;
68 ProtectedVisibilityAttr = MCSA_Protected;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000069 HasLEB128 = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000070 SupportsDebugInformation = false;
Jim Grosbach693e36a2009-08-11 00:09:57 +000071 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000072 DwarfRequiresFrameSection = true;
Devang Patel80be3512009-04-13 17:02:03 +000073 DwarfUsesInlineInfoSection = false;
Devang Patelea636392010-08-31 23:50:19 +000074 DwarfUsesAbsoluteLabelForStmtList = true;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000075 DwarfSectionOffsetDirective = 0;
Devang Patelda3ef852010-09-02 16:43:44 +000076 DwarfUsesLabelOffsetForRanges = true;
Chris Lattner8d99c762010-03-12 21:03:47 +000077 HasMicrosoftFastStdCallMangling = false;
Chris Lattner1472cf52009-08-02 07:24:22 +000078
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000079 AsmTransCBE = 0;
Chris Lattner95129a72006-10-13 17:50:07 +000080}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000081
Chris Lattner7b26fce2009-08-22 20:48:53 +000082MCAsmInfo::~MCAsmInfo() {
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000083}
Chris Lattner95129a72006-10-13 17:50:07 +000084
Anton Korobeynikov942fda02007-03-07 02:47:57 +000085
Chris Lattner7b26fce2009-08-22 20:48:53 +000086unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
Anton Korobeynikovbd890b12008-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 Lattner7b26fce2009-08-22 20:48:53 +000095unsigned MCAsmInfo::getSLEB128Size(int Value) {
Anton Korobeynikovbd890b12008-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}