f346b93ec2477671ce91e77790678e0501722d14
[oota-llvm.git] / lib / MC / MCAsmInfoDarwin.cpp
1 //===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines target asm properties related what form asm statements
11 // should take in general on Darwin-based targets
12 //
13 //===----------------------------------------------------------------------===//
14
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"
20 using namespace llvm;
21
22 bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
23     const MCSection &Section) const {
24   const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
25
26   // Sections holding 1 byte strings are atomized based on the data they
27   // contain.
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())
31     return false;
32
33   if (SMO.getSegmentName() == "__TEXT" &&
34       SMO.getSectionName() == "__objc_classname" &&
35       SMO.getType() == MachO::S_CSTRING_LITERALS)
36     return false;
37
38   if (SMO.getSegmentName() == "__TEXT" &&
39       SMO.getSectionName() == "__objc_methname" &&
40       SMO.getType() == MachO::S_CSTRING_LITERALS)
41     return false;
42
43   if (SMO.getSegmentName() == "__TEXT" &&
44       SMO.getSectionName() == "__objc_methtype" &&
45       SMO.getType() == MachO::S_CSTRING_LITERALS)
46     return false;
47
48   if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
49     return false;
50
51   // no_dead_strip sections are not atomized in practice.
52   if (SMO.hasAttribute(MachO::S_ATTR_NO_DEAD_STRIP))
53     return false;
54
55   switch (SMO.getType()) {
56   default:
57     return true;
58
59   // These sections are atomized at the element boundaries without using
60   // symbols.
61   case MachO::S_4BYTE_LITERALS:
62   case MachO::S_8BYTE_LITERALS:
63   case MachO::S_16BYTE_LITERALS:
64   case MachO::S_LITERAL_POINTERS:
65   case MachO::S_NON_LAZY_SYMBOL_POINTERS:
66   case MachO::S_LAZY_SYMBOL_POINTERS:
67   case MachO::S_MOD_INIT_FUNC_POINTERS:
68   case MachO::S_MOD_TERM_FUNC_POINTERS:
69   case MachO::S_INTERPOSING:
70     return false;
71   }
72 }
73
74 MCAsmInfoDarwin::MCAsmInfoDarwin() {
75   // Common settings for all Darwin targets.
76   // Syntax:
77   LinkerPrivateGlobalPrefix = "l";
78   HasSingleParameterDotFile = false;
79   HasSubsectionsViaSymbols = true;
80
81   AlignmentIsInBytes = false;
82   COMMDirectiveAlignmentIsInBytes = false;
83   LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
84   InlineAsmStart = " InlineAsm Start";
85   InlineAsmEnd = " InlineAsm End";
86
87   // Directives:
88   HasWeakDefDirective = true;
89   HasWeakDefCanBeHiddenDirective = true;
90   WeakRefDirective = "\t.weak_reference ";
91   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
92   HasMachoZeroFillDirective = true;  // Uses .zerofill
93   HasMachoTBSSDirective = true; // Uses .tbss
94   HasStaticCtorDtorReferenceInStaticMode = true;
95
96   // FIXME: Change this once MC is the system assembler.
97   HasAggressiveSymbolFolding = false;
98
99   HiddenVisibilityAttr = MCSA_PrivateExtern;
100   HiddenDeclarationVisibilityAttr = MCSA_Invalid;
101
102   // Doesn't support protected visibility.
103   ProtectedVisibilityAttr = MCSA_Invalid;
104
105   HasDotTypeDotSizeDirective = false;
106   HasNoDeadStrip = true;
107
108   DwarfUsesRelocationsAcrossSections = false;
109
110   UseIntegratedAssembler = true;
111   SetDirectiveSuppressesReloc = true;
112 }