1*9880d681SAndroid Build Coastguard Worker //===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file defines target asm properties related what form asm statements 11*9880d681SAndroid Build Coastguard Worker // should take in general on Darwin-based targets 12*9880d681SAndroid Build Coastguard Worker // 13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCAsmInfoDarwin.h" 16*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCContext.h" 17*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCExpr.h" 18*9880d681SAndroid Build Coastguard Worker #include "llvm/MC/MCSectionMachO.h" 19*9880d681SAndroid Build Coastguard Worker using namespace llvm; 20*9880d681SAndroid Build Coastguard Worker isSectionAtomizableBySymbols(const MCSection & Section) const21*9880d681SAndroid Build Coastguard Workerbool MCAsmInfoDarwin::isSectionAtomizableBySymbols( 22*9880d681SAndroid Build Coastguard Worker const MCSection &Section) const { 23*9880d681SAndroid Build Coastguard Worker const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section); 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker // Sections holding 1 byte strings are atomized based on the data they 26*9880d681SAndroid Build Coastguard Worker // contain. 27*9880d681SAndroid Build Coastguard Worker // Sections holding 2 byte strings require symbols in order to be atomized. 28*9880d681SAndroid Build Coastguard Worker // There is no dedicated section for 4 byte strings. 29*9880d681SAndroid Build Coastguard Worker if (SMO.getType() == MachO::S_CSTRING_LITERALS) 30*9880d681SAndroid Build Coastguard Worker return false; 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Worker if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring") 33*9880d681SAndroid Build Coastguard Worker return false; 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker if (SMO.getSegmentName() == "__DATA" && 36*9880d681SAndroid Build Coastguard Worker SMO.getSectionName() == "__objc_classrefs") 37*9880d681SAndroid Build Coastguard Worker return false; 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Worker switch (SMO.getType()) { 40*9880d681SAndroid Build Coastguard Worker default: 41*9880d681SAndroid Build Coastguard Worker return true; 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Worker // These sections are atomized at the element boundaries without using 44*9880d681SAndroid Build Coastguard Worker // symbols. 45*9880d681SAndroid Build Coastguard Worker case MachO::S_4BYTE_LITERALS: 46*9880d681SAndroid Build Coastguard Worker case MachO::S_8BYTE_LITERALS: 47*9880d681SAndroid Build Coastguard Worker case MachO::S_16BYTE_LITERALS: 48*9880d681SAndroid Build Coastguard Worker case MachO::S_LITERAL_POINTERS: 49*9880d681SAndroid Build Coastguard Worker case MachO::S_NON_LAZY_SYMBOL_POINTERS: 50*9880d681SAndroid Build Coastguard Worker case MachO::S_LAZY_SYMBOL_POINTERS: 51*9880d681SAndroid Build Coastguard Worker case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS: 52*9880d681SAndroid Build Coastguard Worker case MachO::S_MOD_INIT_FUNC_POINTERS: 53*9880d681SAndroid Build Coastguard Worker case MachO::S_MOD_TERM_FUNC_POINTERS: 54*9880d681SAndroid Build Coastguard Worker case MachO::S_INTERPOSING: 55*9880d681SAndroid Build Coastguard Worker return false; 56*9880d681SAndroid Build Coastguard Worker } 57*9880d681SAndroid Build Coastguard Worker } 58*9880d681SAndroid Build Coastguard Worker MCAsmInfoDarwin()59*9880d681SAndroid Build Coastguard WorkerMCAsmInfoDarwin::MCAsmInfoDarwin() { 60*9880d681SAndroid Build Coastguard Worker // Common settings for all Darwin targets. 61*9880d681SAndroid Build Coastguard Worker // Syntax: 62*9880d681SAndroid Build Coastguard Worker LinkerPrivateGlobalPrefix = "l"; 63*9880d681SAndroid Build Coastguard Worker HasSingleParameterDotFile = false; 64*9880d681SAndroid Build Coastguard Worker HasSubsectionsViaSymbols = true; 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker AlignmentIsInBytes = false; 67*9880d681SAndroid Build Coastguard Worker COMMDirectiveAlignmentIsInBytes = false; 68*9880d681SAndroid Build Coastguard Worker LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment; 69*9880d681SAndroid Build Coastguard Worker InlineAsmStart = " InlineAsm Start"; 70*9880d681SAndroid Build Coastguard Worker InlineAsmEnd = " InlineAsm End"; 71*9880d681SAndroid Build Coastguard Worker 72*9880d681SAndroid Build Coastguard Worker // Directives: 73*9880d681SAndroid Build Coastguard Worker HasWeakDefDirective = true; 74*9880d681SAndroid Build Coastguard Worker HasWeakDefCanBeHiddenDirective = true; 75*9880d681SAndroid Build Coastguard Worker WeakRefDirective = "\t.weak_reference "; 76*9880d681SAndroid Build Coastguard Worker ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. 77*9880d681SAndroid Build Coastguard Worker HasMachoZeroFillDirective = true; // Uses .zerofill 78*9880d681SAndroid Build Coastguard Worker HasMachoTBSSDirective = true; // Uses .tbss 79*9880d681SAndroid Build Coastguard Worker HasStaticCtorDtorReferenceInStaticMode = true; 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker // FIXME: Change this once MC is the system assembler. 82*9880d681SAndroid Build Coastguard Worker HasAggressiveSymbolFolding = false; 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker HiddenVisibilityAttr = MCSA_PrivateExtern; 85*9880d681SAndroid Build Coastguard Worker HiddenDeclarationVisibilityAttr = MCSA_Invalid; 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Worker // Doesn't support protected visibility. 88*9880d681SAndroid Build Coastguard Worker ProtectedVisibilityAttr = MCSA_Invalid; 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Worker HasDotTypeDotSizeDirective = false; 91*9880d681SAndroid Build Coastguard Worker HasNoDeadStrip = true; 92*9880d681SAndroid Build Coastguard Worker HasAltEntry = true; 93*9880d681SAndroid Build Coastguard Worker 94*9880d681SAndroid Build Coastguard Worker DwarfUsesRelocationsAcrossSections = false; 95*9880d681SAndroid Build Coastguard Worker 96*9880d681SAndroid Build Coastguard Worker UseIntegratedAssembler = true; 97*9880d681SAndroid Build Coastguard Worker SetDirectiveSuppressesReloc = true; 98*9880d681SAndroid Build Coastguard Worker } 99