1 //===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines target asm properties related what form asm statements
11 // should take in general on Darwin-based targets
13 //===----------------------------------------------------------------------===//
15 #include "llvm/MC/MCAsmInfoDarwin.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCSectionMachO.h"
19 #include "llvm/MC/MCStreamer.h"
22 bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
23 const MCSection &Section) const {
24 const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
26 // Sections holding 1 byte strings are atomized based on the data they
28 // Sections holding 2 byte strings require symbols in order to be atomized.
29 // There is no dedicated section for 4 byte strings.
30 if (SMO.getKind().isMergeable1ByteCString())
33 if (SMO.getSegmentName() == "__TEXT" &&
34 SMO.getSectionName() == "__objc_classname" &&
35 SMO.getType() == MachO::S_CSTRING_LITERALS)
38 if (SMO.getSegmentName() == "__TEXT" &&
39 SMO.getSectionName() == "__objc_methname" &&
40 SMO.getType() == MachO::S_CSTRING_LITERALS)
43 if (SMO.getSegmentName() == "__TEXT" &&
44 SMO.getSectionName() == "__objc_methtype" &&
45 SMO.getType() == MachO::S_CSTRING_LITERALS)
48 if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
51 switch (SMO.getType()) {
55 // These sections are atomized at the element boundaries without using
57 case MachO::S_4BYTE_LITERALS:
58 case MachO::S_8BYTE_LITERALS:
59 case MachO::S_16BYTE_LITERALS:
60 case MachO::S_LITERAL_POINTERS:
61 case MachO::S_NON_LAZY_SYMBOL_POINTERS:
62 case MachO::S_LAZY_SYMBOL_POINTERS:
63 case MachO::S_MOD_INIT_FUNC_POINTERS:
64 case MachO::S_MOD_TERM_FUNC_POINTERS:
65 case MachO::S_INTERPOSING:
70 MCAsmInfoDarwin::MCAsmInfoDarwin() {
71 // Common settings for all Darwin targets.
73 LinkerPrivateGlobalPrefix = "l";
74 HasSingleParameterDotFile = false;
75 HasSubsectionsViaSymbols = true;
77 AlignmentIsInBytes = false;
78 COMMDirectiveAlignmentIsInBytes = false;
79 LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
80 InlineAsmStart = " InlineAsm Start";
81 InlineAsmEnd = " InlineAsm End";
84 HasWeakDefDirective = true;
85 HasWeakDefCanBeHiddenDirective = true;
86 WeakRefDirective = "\t.weak_reference ";
87 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
88 HasMachoZeroFillDirective = true; // Uses .zerofill
89 HasMachoTBSSDirective = true; // Uses .tbss
90 HasStaticCtorDtorReferenceInStaticMode = true;
92 // FIXME: Change this once MC is the system assembler.
93 HasAggressiveSymbolFolding = false;
95 HiddenVisibilityAttr = MCSA_PrivateExtern;
96 HiddenDeclarationVisibilityAttr = MCSA_Invalid;
98 // Doesn't support protected visibility.
99 ProtectedVisibilityAttr = MCSA_Invalid;
101 HasDotTypeDotSizeDirective = false;
102 HasNoDeadStrip = true;
104 DwarfUsesRelocationsAcrossSections = false;
106 UseIntegratedAssembler = true;
107 SetDirectiveSuppressesReloc = true;