Add r224985 back with fixes.
[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.getType() == MachO::S_CSTRING_LITERALS)
31     return false;
32
33   if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
34     return false;
35
36   switch (SMO.getType()) {
37   default:
38     return true;
39
40   // These sections are atomized at the element boundaries without using
41   // symbols.
42   case MachO::S_4BYTE_LITERALS:
43   case MachO::S_8BYTE_LITERALS:
44   case MachO::S_16BYTE_LITERALS:
45   case MachO::S_LITERAL_POINTERS:
46   case MachO::S_NON_LAZY_SYMBOL_POINTERS:
47   case MachO::S_LAZY_SYMBOL_POINTERS:
48   case MachO::S_MOD_INIT_FUNC_POINTERS:
49   case MachO::S_MOD_TERM_FUNC_POINTERS:
50   case MachO::S_INTERPOSING:
51     return false;
52   }
53 }
54
55 MCAsmInfoDarwin::MCAsmInfoDarwin() {
56   // Common settings for all Darwin targets.
57   // Syntax:
58   LinkerPrivateGlobalPrefix = "l";
59   HasSingleParameterDotFile = false;
60   HasSubsectionsViaSymbols = true;
61
62   AlignmentIsInBytes = false;
63   COMMDirectiveAlignmentIsInBytes = false;
64   LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
65   InlineAsmStart = " InlineAsm Start";
66   InlineAsmEnd = " InlineAsm End";
67
68   // Directives:
69   HasWeakDefDirective = true;
70   HasWeakDefCanBeHiddenDirective = true;
71   WeakRefDirective = "\t.weak_reference ";
72   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
73   HasMachoZeroFillDirective = true;  // Uses .zerofill
74   HasMachoTBSSDirective = true; // Uses .tbss
75   HasStaticCtorDtorReferenceInStaticMode = true;
76
77   // FIXME: Change this once MC is the system assembler.
78   HasAggressiveSymbolFolding = false;
79
80   HiddenVisibilityAttr = MCSA_PrivateExtern;
81   HiddenDeclarationVisibilityAttr = MCSA_Invalid;
82
83   // Doesn't support protected visibility.
84   ProtectedVisibilityAttr = MCSA_Invalid;
85
86   HasDotTypeDotSizeDirective = false;
87   HasNoDeadStrip = true;
88
89   DwarfUsesRelocationsAcrossSections = false;
90
91   UseIntegratedAssembler = true;
92   SetDirectiveSuppressesReloc = true;
93 }