blob: 3e5c97d7aa7a40f716881305683f440534d29234 [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 Lattneraf76e592009-08-22 20:48:53 +000021MCAsmInfo::MCAsmInfo() {
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000022 ZeroFillDirective = 0;
23 NonexecutableStackDirective = 0;
24 NeedsSet = false;
25 MaxInstLength = 4;
26 PCSymbol = "$";
27 SeparatorChar = ';';
David Greene014700c2009-07-13 20:25:48 +000028 CommentColumn = 60;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000029 CommentString = "#";
30 GlobalPrefix = "";
31 PrivateGlobalPrefix = ".";
Chris Lattner90f8b702009-07-21 17:30:51 +000032 LinkerPrivateGlobalPrefix = "";
Chris Lattnere2b06012009-08-11 22:39:40 +000033 InlineAsmStart = "APP";
34 InlineAsmEnd = "NO_APP";
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000035 AssemblerDialect = 0;
Chris Lattnera93ca922009-06-18 23:41:35 +000036 AllowQuotesInName = false;
Anton Korobeynikovc6f729e2009-09-18 16:57:42 +000037 AllowNameToStartWithDigit = false;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000038 ZeroDirective = "\t.zero\t";
39 ZeroDirectiveSuffix = 0;
40 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;
55 LCOMMDirective = 0;
56 COMMDirective = "\t.comm\t";
57 COMMDirectiveTakesAlignment = true;
58 HasDotTypeDotSizeDirective = true;
Rafael Espindola952b8392008-12-03 11:01:37 +000059 HasSingleParameterDotFile = true;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000060 UsedDirective = 0;
61 WeakRefDirective = 0;
62 WeakDefDirective = 0;
Chris Lattner33adcfb2009-08-22 21:43:10 +000063 // FIXME: These are ELFish - move to ELFMAI.
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000064 HiddenDirective = "\t.hidden\t";
65 ProtectedDirective = "\t.protected\t";
66 AbsoluteDebugSectionOffsets = false;
67 AbsoluteEHSectionOffsets = false;
68 HasLEB128 = false;
69 HasDotLocAndDotFile = false;
70 SupportsDebugInformation = false;
Jim Grosbach1b747ad2009-08-11 00:09:57 +000071 ExceptionsType = ExceptionHandling::None;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000072 DwarfRequiresFrameSection = true;
Devang Patel0f7fef32009-04-13 17:02:03 +000073 DwarfUsesInlineInfoSection = false;
Chris Lattnere2cf37b2009-07-17 20:46:40 +000074 Is_EHSymbolPrivate = true;
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000075 GlobalEHDirective = 0;
76 SupportsWeakOmittedEHFrame = true;
77 DwarfSectionOffsetDirective = 0;
Chris Lattner18a4c162009-08-02 07:24:22 +000078
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000079 AsmTransCBE = 0;
Chris Lattner4c7b07a2006-10-13 17:50:07 +000080}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +000081
Chris Lattneraf76e592009-08-22 20:48:53 +000082MCAsmInfo::~MCAsmInfo() {
Chris Lattnerf5b10ec2006-10-05 00:35:16 +000083}
Chris Lattner4c7b07a2006-10-13 17:50:07 +000084
Anton Korobeynikova6199c82007-03-07 02:47:57 +000085
Chris Lattneraf76e592009-08-22 20:48:53 +000086unsigned MCAsmInfo::getULEB128Size(unsigned Value) {
Anton Korobeynikovffe31d72008-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 Lattneraf76e592009-08-22 20:48:53 +000095unsigned MCAsmInfo::getSLEB128Size(int Value) {
Anton Korobeynikovffe31d72008-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}