Recommit r224935 with a fix for the ObjC++/AArch64 bug that that revision
[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   switch (SMO.getType()) {
52   default:
53     return true;
54
55   // These sections are atomized at the element boundaries without using
56   // symbols.
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:
66     return false;
67   }
68 }
69
70 MCAsmInfoDarwin::MCAsmInfoDarwin() {
71   // Common settings for all Darwin targets.
72   // Syntax:
73   LinkerPrivateGlobalPrefix = "l";
74   HasSingleParameterDotFile = false;
75   HasSubsectionsViaSymbols = true;
76
77   AlignmentIsInBytes = false;
78   COMMDirectiveAlignmentIsInBytes = false;
79   LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
80   InlineAsmStart = " InlineAsm Start";
81   InlineAsmEnd = " InlineAsm End";
82
83   // Directives:
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;
91
92   // FIXME: Change this once MC is the system assembler.
93   HasAggressiveSymbolFolding = false;
94
95   HiddenVisibilityAttr = MCSA_PrivateExtern;
96   HiddenDeclarationVisibilityAttr = MCSA_Invalid;
97
98   // Doesn't support protected visibility.
99   ProtectedVisibilityAttr = MCSA_Invalid;
100
101   HasDotTypeDotSizeDirective = false;
102   HasNoDeadStrip = true;
103
104   DwarfUsesRelocationsAcrossSections = false;
105
106   UseIntegratedAssembler = true;
107   SetDirectiveSuppressesReloc = true;
108 }