blob: c0777a6e98cc10e25df6743a59fd87189a37a43f [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 Espindolafd057852011-05-01 03:50:49 +000016#include "llvm/MC/MCContext.h"
Rafael Espindolac5dac4d2011-04-28 16:09:09 +000017#include "llvm/MC/MCExpr.h"
18#include "llvm/MC/MCStreamer.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000019#include "llvm/Support/DataTypes.h"
Rafael Espindolafd057852011-05-01 03:50:49 +000020#include "llvm/Support/Dwarf.h"
Dale Johannesen0a1069d2007-04-23 20:00:17 +000021#include <cctype>
22#include <cstring>
Jim Laskey681ecbb2006-09-06 18:35:33 +000023using namespace llvm;
24
Chris Lattner2b4364f2010-01-20 06:34:14 +000025MCAsmInfo::MCAsmInfo() {
Evan Chenga83b37a2011-07-15 02:09:41 +000026 PointerSize = 4;
Eli Bendersky32aab222013-01-23 16:22:04 +000027 CalleeSaveStackSlotSize = 4;
Eli Bendersky0893e102013-01-22 18:02:49 +000028
Evan Chenga83b37a2011-07-15 02:09:41 +000029 IsLittleEndian = true;
30 StackGrowsUp = false;
Chris Lattner76bdea32010-01-23 07:21:06 +000031 HasSubsectionsViaSymbols = false;
Chris Lattner1d371882010-01-19 02:09:44 +000032 HasMachoZeroFillDirective = false;
Eric Christopher27e7ffc2010-05-20 00:49:07 +000033 HasMachoTBSSDirective = false;
Chris Lattnere9d28b12010-01-19 04:34:02 +000034 HasStaticCtorDtorReferenceInStaticMode = false;
Rafael Espindola1048e752010-12-04 00:31:13 +000035 LinkerRequiresNonEmptyDwarfLines = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000036 MaxInstLength = 4;
Ulrich Weigand32d725b2013-06-12 14:46:54 +000037 MinInstAlignment = 1;
David Majnemer0c58bc62013-09-25 10:47:21 +000038 DollarIsPC = false;
Jim Grosbacha3df87f2011-03-24 18:46:34 +000039 SeparatorString = ";";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000040 CommentString = "#";
Chris Lattner7bce0592010-09-22 22:19:53 +000041 LabelSuffix = ":";
Reed Kotleraee4d5d12012-12-16 04:00:45 +000042 DebugLabelSuffix = ":";
Rafael Espindola5113d162013-12-02 23:39:26 +000043 PrivateGlobalPrefix = "L";
Tim Northoverc3988b42014-03-29 07:05:06 +000044 LinkerPrivateGlobalPrefix = "";
Chris Lattnerabdcbc72009-08-11 22:39:40 +000045 InlineAsmStart = "APP";
46 InlineAsmEnd = "NO_APP";
Evan Cheng481ebb02011-07-27 00:38:12 +000047 Code16Directive = ".code16";
48 Code32Directive = ".code32";
49 Code64Directive = ".code64";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000050 AssemblerDialect = 0;
Hans Wennborgce69d772013-10-18 20:46:28 +000051 AllowAtInName = false;
Jim Grosbach4b63d2a2012-05-18 19:12:01 +000052 UseDataRegionDirectives = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000053 ZeroDirective = "\t.zero\t";
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000054 AsciiDirective = "\t.ascii\t";
55 AscizDirective = "\t.asciz\t";
56 Data8bitsDirective = "\t.byte\t";
57 Data16bitsDirective = "\t.short\t";
58 Data32bitsDirective = "\t.long\t";
59 Data64bitsDirective = "\t.quad\t";
Chris Lattnerc9ea8fd2009-08-08 20:43:12 +000060 SunStyleELFSectionSwitchSyntax = false;
Bruno Cardoso Lopes62e6a8b2009-08-13 23:30:21 +000061 UsesELFSectionDirectiveForBSS = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000062 AlignmentIsInBytes = true;
63 TextAlignFillValue = 0;
Craig Topperbb694de2014-04-13 04:57:38 +000064 GPRel64Directive = nullptr;
65 GPRel32Directive = nullptr;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000066 GlobalDirective = "\t.globl\t";
Chris Lattnerff234e02010-01-26 20:40:54 +000067 HasSetDirective = true;
Rafael Espindolaa6cd2d82010-12-22 21:51:29 +000068 HasAggressiveSymbolFolding = true;
Rafael Espindoladcb03f02010-01-26 20:21:43 +000069 COMMDirectiveAlignmentIsInBytes = true;
Benjamin Kramer68b9f052012-09-07 21:08:01 +000070 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000071 HasDotTypeDotSizeDirective = true;
Rafael Espindolacda011b2008-12-03 11:01:37 +000072 HasSingleParameterDotFile = true;
Rafael Espindola5645bad2013-10-16 01:05:45 +000073 HasIdentDirective = false;
Chris Lattner1deb09c2010-01-23 05:51:36 +000074 HasNoDeadStrip = false;
Craig Topperbb694de2014-04-13 04:57:38 +000075 WeakRefDirective = nullptr;
Rafael Espindola04867ce2013-12-02 23:04:51 +000076 HasWeakDefDirective = false;
David Fang1b018492013-12-10 21:37:41 +000077 HasWeakDefCanBeHiddenDirective = false;
Rafael Espindola04867ce2013-12-02 23:04:51 +000078 HasLinkOnceDirective = false;
Chris Lattner0bfd2792010-01-23 06:53:23 +000079 HiddenVisibilityAttr = MCSA_Hidden;
Stuart Hastingsbf836592011-02-23 02:27:05 +000080 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
Chris Lattner0bfd2792010-01-23 06:53:23 +000081 ProtectedVisibilityAttr = MCSA_Protected;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000082 HasLEB128 = false;
Anton Korobeynikov87001fd2008-09-25 21:00:33 +000083 SupportsDebugInformation = false;
Jim Grosbach693e36a2009-08-11 00:09:57 +000084 ExceptionsType = ExceptionHandling::None;
Nick Lewycky33da3362012-06-22 01:25:12 +000085 DwarfUsesRelocationsAcrossSections = true;
Iain Sandoe618def62014-01-08 10:22:54 +000086 DwarfFDESymbolsUseAbsDiff = false;
Akira Hatanaka2f2d9cb2011-07-07 20:30:33 +000087 DwarfRegNumForCFI = false;
Matt Arsenault034ca0f2013-04-22 22:49:11 +000088 NeedsDwarfSectionOffsetDirective = false;
David Peixotto8ad70b32013-12-04 22:43:20 +000089 UseParensForSymbolVariant = false;
Daniel Sanders753e1762014-02-13 14:44:26 +000090
91 // FIXME: Clang's logic should be synced with the logic used to initialize
92 // this member and the two implementations should be merged.
93 // For reference:
94 // - Solaris always enables the integrated assembler by default
95 // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
96 // - Windows always enables the integrated assembler by default
97 // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
98 // - MachO targets always enables the integrated assembler by default
99 // - MCAsmInfoDarwin is handling this case
100 // - Generic_GCC toolchains enable the integrated assembler on a per
101 // architecture basis.
102 // - The target subclasses for AArch64, ARM, and X86 handle these cases
103 UseIntegratedAssembler = false;
David Blaikie7400a972014-03-27 20:45:58 +0000104
105 CompressDebugSections = false;
Chris Lattner95129a72006-10-13 17:50:07 +0000106}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +0000107
Chris Lattner7b26fce2009-08-22 20:48:53 +0000108MCAsmInfo::~MCAsmInfo() {
Chris Lattnerafe6d7a2006-10-05 00:35:16 +0000109}
Chris Lattner95129a72006-10-13 17:50:07 +0000110
Rafael Espindolac5dac4d2011-04-28 16:09:09 +0000111const MCExpr *
112MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
Rafael Espindolafd057852011-05-01 03:50:49 +0000113 unsigned Encoding,
Rafael Espindolac5dac4d2011-04-28 16:09:09 +0000114 MCStreamer &Streamer) const {
Rafael Espindolafd057852011-05-01 03:50:49 +0000115 return getExprForFDESymbol(Sym, Encoding, Streamer);
Rafael Espindola6bd6a702011-04-28 21:04:39 +0000116}
117
118const MCExpr *
119MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
Rafael Espindolafd057852011-05-01 03:50:49 +0000120 unsigned Encoding,
Rafael Espindola6bd6a702011-04-28 21:04:39 +0000121 MCStreamer &Streamer) const {
Rafael Espindolafd057852011-05-01 03:50:49 +0000122 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
123 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
124
125 MCContext &Context = Streamer.getContext();
126 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
127 MCSymbol *PCSym = Context.CreateTempSymbol();
128 Streamer.EmitLabel(PCSym);
129 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
130 return MCBinaryExpr::CreateSub(Res, PC, Context);
Rafael Espindolac5dac4d2011-04-28 16:09:09 +0000131}