blob: 547f904d70f47d727b14e3c5717544d967128ee8 [file] [log] [blame]
Chris Lattneraf76e592009-08-22 20:48:53 +00001//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
Jim Laskeyec0d9fe2006-09-06 18:35:33 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-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 Laskeyec0d9fe2006-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 Lattneraf76e592009-08-22 20:48:53 +000015#include "llvm/MC/MCAsmInfo.h"
Chandler Carruth8b67f772009-10-26 01:35:46 +000016#include "llvm/System/DataTypes.h"
Dale Johannesen3bb62832007-04-23 20:00:17 +000017#include <cctype>
18#include <cstring>
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000019using namespace llvm;
20
Chris Lattner8eeba352010-01-20 06:34:14 +000021MCAsmInfo::MCAsmInfo() {
Chris Lattnerf9f93e42010-01-23 07:21:06 +000022 HasSubsectionsViaSymbols = false;
Chris Lattneraac138e2010-01-19 02:09:44 +000023 HasMachoZeroFillDirective = false;
Chris Lattner71eae712010-01-19 04:34:02 +000024 HasStaticCtorDtorReferenceInStaticMode = false;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000025 NeedsSet = false;
26 MaxInstLength = 4;
27 PCSymbol = "$";
28 SeparatorChar = ';';
David Greene014700c2009-07-13 20:25:48 +000029 CommentColumn = 60;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000030 CommentString = "#";
31 GlobalPrefix = "";
32 PrivateGlobalPrefix = ".";
Chris Lattner90f8b702009-07-21 17:30:51 +000033 LinkerPrivateGlobalPrefix = "";
Chris Lattnere2b06012009-08-11 22:39:40 +000034 InlineAsmStart = "APP";
35 InlineAsmEnd = "NO_APP";
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000036 AssemblerDialect = 0;
Chris Lattnera93ca922009-06-18 23:41:35 +000037 AllowQuotesInName = false;
Anton Korobeynikovc6f729e2009-09-18 16:57:42 +000038 AllowNameToStartWithDigit = false;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000039 ZeroDirective = "\t.zero\t";
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000040 AsciiDirective = "\t.ascii\t";
41 AscizDirective = "\t.asciz\t";
42 Data8bitsDirective = "\t.byte\t";
43 Data16bitsDirective = "\t.short\t";
44 Data32bitsDirective = "\t.long\t";
45 Data64bitsDirective = "\t.quad\t";
Chris Lattner5277b222009-08-08 20:43:12 +000046 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopesfdf229e2009-08-13 23:30:21 +000047 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000048 AlignDirective = "\t.align\t";
49 AlignmentIsInBytes = true;
50 TextAlignFillValue = 0;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000051 JumpTableDirective = 0;
Chris Lattnerdfab2912009-08-11 20:30:58 +000052 PICJumpTableDirective = 0;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000053 GlobalDirective = "\t.globl\t";
54 SetDirective = 0;
Chris Lattner9eb158d2010-01-23 07:47:02 +000055 HasLCOMMDirective = false;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000056 COMMDirectiveTakesAlignment = true;
57 HasDotTypeDotSizeDirective = true;
Rafael Espindola952b8392008-12-03 11:01:37 +000058 HasSingleParameterDotFile = true;
Chris Lattner3a9be0e2010-01-23 05:51:36 +000059 HasNoDeadStrip = false;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000060 WeakRefDirective = 0;
61 WeakDefDirective = 0;
Chris Lattner41eb8b42010-01-19 05:08:13 +000062 LinkOnceDirective = 0;
Chris Lattner152a29b2010-01-23 06:53:23 +000063 HiddenVisibilityAttr = MCSA_Hidden;
64 ProtectedVisibilityAttr = MCSA_Protected;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000065 AbsoluteDebugSectionOffsets = false;
66 AbsoluteEHSectionOffsets = false;
67 HasLEB128 = false;
68 HasDotLocAndDotFile = false;
69 SupportsDebugInformation = false;
Jim Grosbach1b747ad2009-08-11 00:09:57 +000070 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000071 DwarfRequiresFrameSection = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000072 DwarfUsesInlineInfoSection = false;
Chris Lattnere2cf37b2009-07-17 20:46:40 +000073 Is_EHSymbolPrivate = true;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000074 GlobalEHDirective = 0;
75 SupportsWeakOmittedEHFrame = true;
76 DwarfSectionOffsetDirective = 0;
Chris Lattner18a4c162009-08-02 07:24:22 +000077
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000078 AsmTransCBE = 0;
Chris Lattner4c7b07a2006-10-13 17:50:07 +000079}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +000080
Chris Lattneraf76e592009-08-22 20:48:53 +000081MCAsmInfo::~MCAsmInfo() {
Chris Lattnerf5b10ec2006-10-05 00:35:16 +000082}
Chris Lattner4c7b07a2006-10-13 17:50:07 +000083
Anton Korobeynikova6199c82007-03-07 02:47:57 +000084
Chris Lattneraf76e592009-08-22 20:48:53 +000085unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
Anton Korobeynikovffe31d72008-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 Lattneraf76e592009-08-22 20:48:53 +000094unsigned MCAsmInfo::getSLEB128Size(int Value) {
Anton Korobeynikovffe31d72008-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}