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