2009-08-22 22:48:53 +02:00
|
|
|
//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
|
2006-09-06 20:35:33 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-09-06 20:35:33 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines target asm properties related what form asm statements
|
|
|
|
// should take.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-08-22 22:48:53 +02:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2011-05-01 05:50:49 +02:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2011-04-28 18:09:09 +02:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2010-11-29 19:16:10 +01:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2011-05-01 05:50:49 +02:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
2007-04-23 22:00:17 +02:00
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
2006-09-06 20:35:33 +02:00
|
|
|
using namespace llvm;
|
|
|
|
|
2010-01-20 07:34:14 +01:00
|
|
|
MCAsmInfo::MCAsmInfo() {
|
2011-07-15 04:09:41 +02:00
|
|
|
PointerSize = 4;
|
2013-01-23 17:22:04 +01:00
|
|
|
CalleeSaveStackSlotSize = 4;
|
2013-01-22 19:02:49 +01:00
|
|
|
|
2011-07-15 04:09:41 +02:00
|
|
|
IsLittleEndian = true;
|
|
|
|
StackGrowsUp = false;
|
2010-01-23 08:21:06 +01:00
|
|
|
HasSubsectionsViaSymbols = false;
|
2010-01-19 03:09:44 +01:00
|
|
|
HasMachoZeroFillDirective = false;
|
2010-05-20 02:49:07 +02:00
|
|
|
HasMachoTBSSDirective = false;
|
2010-01-19 05:34:02 +01:00
|
|
|
HasStaticCtorDtorReferenceInStaticMode = false;
|
2008-09-25 23:00:33 +02:00
|
|
|
MaxInstLength = 4;
|
2013-06-12 16:46:54 +02:00
|
|
|
MinInstAlignment = 1;
|
2013-09-25 12:47:21 +02:00
|
|
|
DollarIsPC = false;
|
2011-03-24 19:46:34 +01:00
|
|
|
SeparatorString = ";";
|
2008-09-25 23:00:33 +02:00
|
|
|
CommentString = "#";
|
2010-09-23 00:19:53 +02:00
|
|
|
LabelSuffix = ":";
|
2014-06-25 00:45:16 +02:00
|
|
|
UseAssignmentForEHBegin = false;
|
2015-03-05 19:55:50 +01:00
|
|
|
NeedsLocalForSize = false;
|
2013-12-03 00:39:26 +01:00
|
|
|
PrivateGlobalPrefix = "L";
|
2014-12-04 01:06:57 +01:00
|
|
|
PrivateLabelPrefix = PrivateGlobalPrefix;
|
2014-03-29 08:05:06 +01:00
|
|
|
LinkerPrivateGlobalPrefix = "";
|
2009-08-12 00:39:40 +02:00
|
|
|
InlineAsmStart = "APP";
|
|
|
|
InlineAsmEnd = "NO_APP";
|
2011-07-27 02:38:12 +02:00
|
|
|
Code16Directive = ".code16";
|
|
|
|
Code32Directive = ".code32";
|
|
|
|
Code64Directive = ".code64";
|
2008-09-25 23:00:33 +02:00
|
|
|
AssemblerDialect = 0;
|
2013-10-18 22:46:28 +02:00
|
|
|
AllowAtInName = false;
|
2015-06-09 02:31:39 +02:00
|
|
|
SupportsQuotedNames = true;
|
2012-05-18 21:12:01 +02:00
|
|
|
UseDataRegionDirectives = false;
|
2008-09-25 23:00:33 +02:00
|
|
|
ZeroDirective = "\t.zero\t";
|
|
|
|
AsciiDirective = "\t.ascii\t";
|
|
|
|
AscizDirective = "\t.asciz\t";
|
|
|
|
Data8bitsDirective = "\t.byte\t";
|
|
|
|
Data16bitsDirective = "\t.short\t";
|
|
|
|
Data32bitsDirective = "\t.long\t";
|
|
|
|
Data64bitsDirective = "\t.quad\t";
|
2009-08-08 22:43:12 +02:00
|
|
|
SunStyleELFSectionSwitchSyntax = false;
|
2009-08-14 01:30:21 +02:00
|
|
|
UsesELFSectionDirectiveForBSS = false;
|
2008-09-25 23:00:33 +02:00
|
|
|
AlignmentIsInBytes = true;
|
|
|
|
TextAlignFillValue = 0;
|
2014-04-13 06:57:38 +02:00
|
|
|
GPRel64Directive = nullptr;
|
|
|
|
GPRel32Directive = nullptr;
|
2008-09-25 23:00:33 +02:00
|
|
|
GlobalDirective = "\t.globl\t";
|
2014-10-21 03:17:30 +02:00
|
|
|
SetDirectiveSuppressesReloc = false;
|
2010-12-22 22:51:29 +01:00
|
|
|
HasAggressiveSymbolFolding = true;
|
2010-01-26 21:21:43 +01:00
|
|
|
COMMDirectiveAlignmentIsInBytes = true;
|
2012-09-07 23:08:01 +02:00
|
|
|
LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
|
2015-03-12 02:50:30 +01:00
|
|
|
HasFunctionAlignment = true;
|
2008-09-25 23:00:33 +02:00
|
|
|
HasDotTypeDotSizeDirective = true;
|
2008-12-03 12:01:37 +01:00
|
|
|
HasSingleParameterDotFile = true;
|
2013-10-16 03:05:45 +02:00
|
|
|
HasIdentDirective = false;
|
2010-01-23 06:51:36 +01:00
|
|
|
HasNoDeadStrip = false;
|
2014-12-01 22:16:17 +01:00
|
|
|
WeakDirective = "\t.weak\t";
|
2014-04-13 06:57:38 +02:00
|
|
|
WeakRefDirective = nullptr;
|
2013-12-03 00:04:51 +01:00
|
|
|
HasWeakDefDirective = false;
|
2013-12-10 22:37:41 +01:00
|
|
|
HasWeakDefCanBeHiddenDirective = false;
|
2013-12-03 00:04:51 +01:00
|
|
|
HasLinkOnceDirective = false;
|
2010-01-23 07:53:23 +01:00
|
|
|
HiddenVisibilityAttr = MCSA_Hidden;
|
2011-02-23 03:27:05 +01:00
|
|
|
HiddenDeclarationVisibilityAttr = MCSA_Hidden;
|
2010-01-23 07:53:23 +01:00
|
|
|
ProtectedVisibilityAttr = MCSA_Protected;
|
2008-09-25 23:00:33 +02:00
|
|
|
SupportsDebugInformation = false;
|
2009-08-11 02:09:57 +02:00
|
|
|
ExceptionsType = ExceptionHandling::None;
|
2014-09-02 01:48:29 +02:00
|
|
|
WinEHEncodingType = WinEH::EncodingType::Invalid;
|
2012-06-22 03:25:12 +02:00
|
|
|
DwarfUsesRelocationsAcrossSections = true;
|
2014-01-08 11:22:54 +01:00
|
|
|
DwarfFDESymbolsUseAbsDiff = false;
|
2011-07-07 22:30:33 +02:00
|
|
|
DwarfRegNumForCFI = false;
|
2013-04-23 00:49:11 +02:00
|
|
|
NeedsDwarfSectionOffsetDirective = false;
|
2013-12-04 23:43:20 +01:00
|
|
|
UseParensForSymbolVariant = false;
|
2015-04-28 03:37:11 +02:00
|
|
|
UseLogicalShr = true;
|
2014-02-13 15:44:26 +01:00
|
|
|
|
|
|
|
// FIXME: Clang's logic should be synced with the logic used to initialize
|
|
|
|
// this member and the two implementations should be merged.
|
|
|
|
// For reference:
|
|
|
|
// - Solaris always enables the integrated assembler by default
|
|
|
|
// - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
|
|
|
|
// - Windows always enables the integrated assembler by default
|
|
|
|
// - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
|
|
|
|
// - MachO targets always enables the integrated assembler by default
|
|
|
|
// - MCAsmInfoDarwin is handling this case
|
|
|
|
// - Generic_GCC toolchains enable the integrated assembler on a per
|
|
|
|
// architecture basis.
|
2014-06-11 06:19:25 +02:00
|
|
|
// - The target subclasses for AArch64, ARM, and X86 handle these cases
|
2014-02-13 15:44:26 +01:00
|
|
|
UseIntegratedAssembler = false;
|
2014-03-27 21:45:58 +01:00
|
|
|
|
|
|
|
CompressDebugSections = false;
|
2006-10-13 19:50:07 +02:00
|
|
|
}
|
2006-10-05 02:35:16 +02:00
|
|
|
|
2009-08-22 22:48:53 +02:00
|
|
|
MCAsmInfo::~MCAsmInfo() {
|
2006-10-05 02:35:16 +02:00
|
|
|
}
|
2006-10-13 19:50:07 +02:00
|
|
|
|
2015-01-09 19:55:42 +01:00
|
|
|
bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-28 18:09:09 +02:00
|
|
|
const MCExpr *
|
|
|
|
MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
2011-05-01 05:50:49 +02:00
|
|
|
unsigned Encoding,
|
2011-04-28 18:09:09 +02:00
|
|
|
MCStreamer &Streamer) const {
|
2011-05-01 05:50:49 +02:00
|
|
|
return getExprForFDESymbol(Sym, Encoding, Streamer);
|
2011-04-28 23:04:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const MCExpr *
|
|
|
|
MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
|
2011-05-01 05:50:49 +02:00
|
|
|
unsigned Encoding,
|
2011-04-28 23:04:39 +02:00
|
|
|
MCStreamer &Streamer) const {
|
2011-05-01 05:50:49 +02:00
|
|
|
if (!(Encoding & dwarf::DW_EH_PE_pcrel))
|
2015-05-30 03:25:56 +02:00
|
|
|
return MCSymbolRefExpr::create(Sym, Streamer.getContext());
|
2011-05-01 05:50:49 +02:00
|
|
|
|
|
|
|
MCContext &Context = Streamer.getContext();
|
2015-05-30 03:25:56 +02:00
|
|
|
const MCExpr *Res = MCSymbolRefExpr::create(Sym, Context);
|
2015-05-18 20:43:14 +02:00
|
|
|
MCSymbol *PCSym = Context.createTempSymbol();
|
2011-05-01 05:50:49 +02:00
|
|
|
Streamer.EmitLabel(PCSym);
|
2015-05-30 03:25:56 +02:00
|
|
|
const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
|
|
|
|
return MCBinaryExpr::createSub(Res, PC, Context);
|
2011-04-28 18:09:09 +02:00
|
|
|
}
|
2015-06-09 02:31:39 +02:00
|
|
|
|
|
|
|
static bool isAcceptableChar(char C) {
|
|
|
|
return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
|
|
|
|
(C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
|
|
|
|
if (Name.empty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// If any of the characters in the string is an unacceptable character, force
|
|
|
|
// quotes.
|
|
|
|
for (char C : Name) {
|
|
|
|
if (!isAcceptableChar(C))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
MCAsmInfo: Allow targets to specify when the .section directive should be omitted
Summary:
The default behavior is to omit the .section directive for .text, .data,
and sometimes .bss, but some targets may want to omit this directive for
other sections too.
The AMDGPU backend will uses this to emit a simplified syntax for section
switches. For example if the section directive is not omitted (current
behavior), section switches to .hsatext will be printed like this:
.section .hsatext,#alloc,#execinstr,#write
This is actually wrong, because .hsatext has some custom STT_* flags,
which MC doesn't know how to print or parse.
If the section directive is omitted (made possible by this commit),
section switches will be printed like this:
.hsatext
The motivation for this patch is to make it possible to emit sections
with custom STT_* flags without having to teach MC about all the target
specific STT_* flags.
Reviewers: rafael, grosbach
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D12423
llvm-svn: 248618
2015-09-25 23:41:14 +02:00
|
|
|
|
|
|
|
bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
|
|
|
|
// FIXME: Does .section .bss/.data/.text work everywhere??
|
|
|
|
return SectionName == ".text" || SectionName == ".data" ||
|
|
|
|
(SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
|
|
|
|
}
|