blob: 873802ae9806c2deab98120c799385005a589c92 [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"
Rafael Espindolac5dac4d2011-04-28 16:09:09 +000016#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCStreamer.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000018#include "llvm/Support/DataTypes.h"
Dale Johannesen0a1069d2007-04-23 20:00:17 +000019#include <cctype>
20#include <cstring>
Jim Laskey681ecbb2006-09-06 18:35:33 +000021using namespace llvm;
22
Chris Lattner2b4364f2010-01-20 06:34:14 +000023MCAsmInfo::MCAsmInfo() {
Chris Lattner76bdea32010-01-23 07:21:06 +000024 HasSubsectionsViaSymbols = false;
Chris Lattner1d371882010-01-19 02:09:44 +000025 HasMachoZeroFillDirective = false;
Eric Christopher27e7ffc2010-05-20 00:49:07 +000026 HasMachoTBSSDirective = false;
Chris Lattnere9d28b12010-01-19 04:34:02 +000027 HasStaticCtorDtorReferenceInStaticMode = false;
Rafael Espindola1048e752010-12-04 00:31:13 +000028 LinkerRequiresNonEmptyDwarfLines = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000029 MaxInstLength = 4;
30 PCSymbol = "$";
Jim Grosbacha3df87f2011-03-24 18:46:34 +000031 SeparatorString = ";";
Daniel Dunbar675ae272010-02-05 07:32:18 +000032 CommentColumn = 40;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000033 CommentString = "#";
Chris Lattner7bce0592010-09-22 22:19:53 +000034 LabelSuffix = ":";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000035 GlobalPrefix = "";
36 PrivateGlobalPrefix = ".";
Chris Lattner1177cee2009-07-21 17:30:51 +000037 LinkerPrivateGlobalPrefix = "";
Chris Lattnerabdcbc72009-08-11 22:39:40 +000038 InlineAsmStart = "APP";
39 InlineAsmEnd = "NO_APP";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000040 AssemblerDialect = 0;
Chris Lattnerb8476452009-06-18 23:41:35 +000041 AllowQuotesInName = false;
Anton Korobeynikov592638a2009-09-18 16:57:42 +000042 AllowNameToStartWithDigit = false;
Mon P Wangb0a0a262010-04-29 04:00:56 +000043 AllowPeriodsInName = true;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000044 ZeroDirective = "\t.zero\t";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000045 AsciiDirective = "\t.ascii\t";
46 AscizDirective = "\t.asciz\t";
47 Data8bitsDirective = "\t.byte\t";
48 Data16bitsDirective = "\t.short\t";
49 Data32bitsDirective = "\t.long\t";
50 Data64bitsDirective = "\t.quad\t";
Chris Lattnerc9ea8fd2009-08-08 20:43:12 +000051 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes62e6a8b2009-08-13 23:30:21 +000052 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000053 AlignDirective = "\t.align\t";
54 AlignmentIsInBytes = true;
55 TextAlignFillValue = 0;
Chris Lattner19bd0392010-01-25 21:10:10 +000056 GPRel32Directive = 0;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000057 GlobalDirective = "\t.globl\t";
Chris Lattnerff234e02010-01-26 20:40:54 +000058 HasSetDirective = true;
Rafael Espindolaa6cd2d82010-12-22 21:51:29 +000059 HasAggressiveSymbolFolding = true;
Chris Lattnerb1301f72010-01-23 07:47:02 +000060 HasLCOMMDirective = false;
Rafael Espindoladcb03f02010-01-26 20:21:43 +000061 COMMDirectiveAlignmentIsInBytes = true;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000062 HasDotTypeDotSizeDirective = true;
Rafael Espindolacda011b2008-12-03 11:01:37 +000063 HasSingleParameterDotFile = true;
Chris Lattner1deb09c2010-01-23 05:51:36 +000064 HasNoDeadStrip = false;
Kevin Enderby8be14412010-11-19 18:39:33 +000065 HasSymbolResolver = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000066 WeakRefDirective = 0;
67 WeakDefDirective = 0;
Chris Lattnerb1f29342010-01-19 05:08:13 +000068 LinkOnceDirective = 0;
Chris Lattner0bfd2792010-01-23 06:53:23 +000069 HiddenVisibilityAttr = MCSA_Hidden;
Stuart Hastingsbf836592011-02-23 02:27:05 +000070 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
Chris Lattner0bfd2792010-01-23 06:53:23 +000071 ProtectedVisibilityAttr = MCSA_Protected;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000072 HasLEB128 = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000073 SupportsDebugInformation = false;
Jim Grosbach693e36a2009-08-11 00:09:57 +000074 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000075 DwarfRequiresFrameSection = true;
Devang Patel80be3512009-04-13 17:02:03 +000076 DwarfUsesInlineInfoSection = false;
Devang Patelea636392010-08-31 23:50:19 +000077 DwarfUsesAbsoluteLabelForStmtList = true;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000078 DwarfSectionOffsetDirective = 0;
Devang Patelda3ef852010-09-02 16:43:44 +000079 DwarfUsesLabelOffsetForRanges = true;
Chris Lattner8d99c762010-03-12 21:03:47 +000080 HasMicrosoftFastStdCallMangling = false;
Chris Lattner1472cf52009-08-02 07:24:22 +000081
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000082 AsmTransCBE = 0;
Chris Lattner95129a72006-10-13 17:50:07 +000083}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000084
Chris Lattner7b26fce2009-08-22 20:48:53 +000085MCAsmInfo::~MCAsmInfo() {
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000086}
Chris Lattner95129a72006-10-13 17:50:07 +000087
Anton Korobeynikov942fda02007-03-07 02:47:57 +000088
Chris Lattner7b26fce2009-08-22 20:48:53 +000089unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
Anton Korobeynikovbd890b12008-08-16 12:57:46 +000090 unsigned Size = 0;
91 do {
92 Value >>= 7;
93 Size += sizeof(int8_t);
94 } while (Value);
95 return Size;
96}
97
Chris Lattner7b26fce2009-08-22 20:48:53 +000098unsigned MCAsmInfo::getSLEB128Size(int Value) {
Anton Korobeynikovbd890b12008-08-16 12:57:46 +000099 unsigned Size = 0;
100 int Sign = Value >> (8 * sizeof(Value) - 1);
101 bool IsMore;
102
103 do {
104 unsigned Byte = Value & 0x7f;
105 Value >>= 7;
106 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
107 Size += sizeof(int8_t);
108 } while (IsMore);
109 return Size;
110}
Rafael Espindolac5dac4d2011-04-28 16:09:09 +0000111
112const MCExpr *
113MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
114 MCStreamer &Streamer) const {
115 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
116}