LLVM  13.0.0git
MCAsmInfoDarwin.cpp
Go to the documentation of this file.
1 //===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines target asm properties related what form asm statements
10 // should take in general on Darwin-based targets
11 //
12 //===----------------------------------------------------------------------===//
13 
16 #include "llvm/MC/MCDirectives.h"
17 #include "llvm/MC/MCSectionMachO.h"
18 
19 using namespace llvm;
20 
22  const MCSection &Section) const {
23  const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
24 
25  // Sections holding 1 byte strings are atomized based on the data they
26  // contain.
27  // Sections holding 2 byte strings require symbols in order to be atomized.
28  // There is no dedicated section for 4 byte strings.
30  return false;
31 
32  if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__cfstring")
33  return false;
34 
35  if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__objc_classrefs")
36  return false;
37 
38  switch (SMO.getType()) {
39  default:
40  return true;
41 
42  // These sections are atomized at the element boundaries without using
43  // symbols.
54  return false;
55  }
56 }
57 
59  // Common settings for all Darwin targets.
60  // Syntax:
64 
65  AlignmentIsInBytes = false;
68  InlineAsmStart = " InlineAsm Start";
69  InlineAsmEnd = " InlineAsm End";
70 
71  // Directives:
72  HasWeakDefDirective = true;
74  WeakRefDirective = "\t.weak_reference ";
75  ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
76  HasMachoZeroFillDirective = true; // Uses .zerofill
77  HasMachoTBSSDirective = true; // Uses .tbss
78 
79  // FIXME: Change this once MC is the system assembler.
81 
84 
85  // Doesn't support protected visibility.
87 
89  HasNoDeadStrip = true;
90  HasAltEntry = true;
91 
94 }
llvm::MachO::S_CSTRING_LITERALS
@ S_CSTRING_LITERALS
S_CSTRING_LITERALS - Section with literal C strings.
Definition: MachO.h:129
llvm::MCAsmInfo::HasMachoTBSSDirective
bool HasMachoTBSSDirective
True if this is a MachO target that supports the macho-specific .tbss directive for emitting thread l...
Definition: MCAsmInfo.h:94
llvm
Definition: AllocatorList.h:23
MCAsmInfoDarwin.h
llvm::MCAsmInfo::HasMachoZeroFillDirective
bool HasMachoZeroFillDirective
True if this is a MachO target that supports the macho-specific .zerofill directive for emitting BSS ...
Definition: MCAsmInfo.h:90
MCDirectives.h
llvm::MCSA_Invalid
@ MCSA_Invalid
Not a valid directive.
Definition: MCDirectives.h:19
llvm::MCAsmInfo::AlignmentIsInBytes
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition: MCAsmInfo.h:326
llvm::MCAsmInfo::HasNoDeadStrip
bool HasNoDeadStrip
True if this target supports the MachO .no_dead_strip directive.
Definition: MCAsmInfo.h:396
llvm::MachO::S_LITERAL_POINTERS
@ S_LITERAL_POINTERS
S_LITERAL_POINTERS - Section with pointers to literals.
Definition: MachO.h:135
llvm::LCOMM::Log2Alignment
@ Log2Alignment
Definition: MCAsmInfo.h:50
llvm::MCAsmInfo::InlineAsmEnd
const char * InlineAsmEnd
Definition: MCAsmInfo.h:180
llvm::MCAsmInfo::SetDirectiveSuppressesReloc
bool SetDirectiveSuppressesReloc
True if the expression .long f - g uses a relocation but it can be suppressed by writing a = f - g ....
Definition: MCAsmInfo.h:343
llvm::MCAsmInfoDarwin::isSectionAtomizableBySymbols
bool isSectionAtomizableBySymbols(const MCSection &Section) const override
True if the section is atomized using the symbols in it.
Definition: MCAsmInfoDarwin.cpp:21
llvm::MachO::S_8BYTE_LITERALS
@ S_8BYTE_LITERALS
S_8BYTE_LITERALS - Section with 8 byte literals.
Definition: MachO.h:133
llvm::MCAsmInfo::DwarfUsesRelocationsAcrossSections
bool DwarfUsesRelocationsAcrossSections
True if Dwarf2 output generally uses relocations for references to other .debug_* sections.
Definition: MCAsmInfo.h:452
llvm::MachO::S_MOD_TERM_FUNC_POINTERS
@ S_MOD_TERM_FUNC_POINTERS
S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for termination.
Definition: MachO.h:148
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::MCSectionMachO::getType
MachO::SectionType getType() const
Definition: MCSectionMachO.h:50
llvm::MCAsmInfo::ProtectedVisibilityAttr
MCSymbolAttr ProtectedVisibilityAttr
This attribute, if not MCSA_Invalid, is used to declare a symbol as having protected visibility.
Definition: MCAsmInfo.h:432
llvm::MCAsmInfo::HasSingleParameterDotFile
bool HasSingleParameterDotFile
True if the target has a single parameter .file directive, this is true for ELF targets.
Definition: MCAsmInfo.h:388
MCSectionMachO.h
llvm::MCAsmInfo::HasWeakDefDirective
bool HasWeakDefDirective
True if we have a directive to declare a global as being a weak defined symbol.
Definition: MCAsmInfo.h:411
llvm::MCAsmInfo::LinkerPrivateGlobalPrefix
StringRef LinkerPrivateGlobalPrefix
This prefix is used for symbols that should be passed through the assembler but be removed by the lin...
Definition: MCAsmInfo.h:175
llvm::MachO::S_LAZY_SYMBOL_POINTERS
@ S_LAZY_SYMBOL_POINTERS
S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
Definition: MachO.h:139
llvm::MCAsmInfo::HasDotTypeDotSizeDirective
bool HasDotTypeDotSizeDirective
True if the target has .type and .size directives, this is true for most ELF targets.
Definition: MCAsmInfo.h:384
llvm::MachO::S_INTERPOSING
@ S_INTERPOSING
S_INTERPOSING - Section with only pairs of function pointers for interposing.
Definition: MachO.h:156
llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS
@ S_NON_LAZY_SYMBOL_POINTERS
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
Definition: MachO.h:137
llvm::MCAsmInfo::HasSubsectionsViaSymbols
bool HasSubsectionsViaSymbols
True if this target has the MachO .subsections_via_symbols directive.
Definition: MCAsmInfo.h:86
llvm::MCAsmInfo::WeakRefDirective
const char * WeakRefDirective
This directive, if non-null, is used to declare a global as being a weak undefined symbol.
Definition: MCAsmInfo.h:407
llvm::MachO::S_MOD_INIT_FUNC_POINTERS
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
Definition: MachO.h:145
llvm::MCAsmInfo::COMMDirectiveAlignmentIsInBytes
bool COMMDirectiveAlignmentIsInBytes
True is .comm's and .lcomms optional alignment is to be specified in bytes instead of log2(n).
Definition: MCAsmInfo.h:362
llvm::MCAsmInfo::HasAltEntry
bool HasAltEntry
True if this target supports the MachO .alt_entry directive.
Definition: MCAsmInfo.h:400
llvm::MCAsmInfo::ZeroDirective
const char * ZeroDirective
This should be set to the directive used to get some number of zero (and non-zero if supported by the...
Definition: MCAsmInfo.h:246
llvm::MCAsmInfo::HasWeakDefCanBeHiddenDirective
bool HasWeakDefCanBeHiddenDirective
True if we have a directive to declare a global as being a weak defined symbol that can be hidden (un...
Definition: MCAsmInfo.h:415
llvm::MachO::S_4BYTE_LITERALS
@ S_4BYTE_LITERALS
S_4BYTE_LITERALS - Section with 4 byte literals.
Definition: MachO.h:131
llvm::MCAsmInfo::HiddenDeclarationVisibilityAttr
MCSymbolAttr HiddenDeclarationVisibilityAttr
This attribute, if not MCSA_Invalid, is used to declare an undefined symbol as having hidden visibili...
Definition: MCAsmInfo.h:428
llvm::MCAsmInfo::InlineAsmStart
const char * InlineAsmStart
If these are nonempty, they contain a directive to emit before and after an inline assembly statement...
Definition: MCAsmInfo.h:179
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
llvm::MachO::S_16BYTE_LITERALS
@ S_16BYTE_LITERALS
S_16BYTE_LITERALS - Section with only 16 byte literals.
Definition: MachO.h:158
llvm::MCSection::getName
StringRef getName() const
Definition: MCSection.h:115
llvm::MCAsmInfoDarwin::MCAsmInfoDarwin
MCAsmInfoDarwin()
Definition: MCAsmInfoDarwin.cpp:58
llvm::MachO::S_THREAD_LOCAL_VARIABLE_POINTERS
@ S_THREAD_LOCAL_VARIABLE_POINTERS
S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread local structures.
Definition: MachO.h:173
llvm::MCSectionMachO
This represents a section on a Mach-O system (used by Mac OS X).
Definition: MCSectionMachO.h:24
llvm::MCSectionMachO::getSegmentName
StringRef getSegmentName() const
Definition: MCSectionMachO.h:40
llvm::MCAsmInfo::HiddenVisibilityAttr
MCSymbolAttr HiddenVisibilityAttr
This attribute, if not MCSA_Invalid, is used to declare a symbol as having hidden visibility.
Definition: MCAsmInfo.h:424
llvm::MCAsmInfo::LCOMMDirectiveAlignmentType
LCOMM::LCOMMType LCOMMDirectiveAlignmentType
Describes if the .lcomm directive for the target supports an alignment argument and how it is interpr...
Definition: MCAsmInfo.h:366
llvm::MCAsmInfo::HasAggressiveSymbolFolding
bool HasAggressiveSymbolFolding
False if the assembler requires that we use.
Definition: MCAsmInfo.h:358
llvm::MCSA_PrivateExtern
@ MCSA_PrivateExtern
.private_extern (MachO)
Definition: MCDirectives.h:41
MachO.h