blob: 04cc0ff4a864c4d1113348bf9d80b753d10ddb0e [file] [log] [blame]
Chris Lattner7b26fce2009-08-22 20:48:53 +00001//===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===//
Anton Korobeynikovc1874382008-07-19 13:14:46 +00002//
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
Chris Lattner7b26fce2009-08-22 20:48:53 +000015#include "llvm/MC/MCAsmInfoDarwin.h"
Rafael Espindolac5dac4d2011-04-28 16:09:09 +000016#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCExpr.h"
Lang Hames1e923ec2015-01-09 18:55:42 +000018#include "llvm/MC/MCSectionMachO.h"
Rafael Espindolac5dac4d2011-04-28 16:09:09 +000019#include "llvm/MC/MCStreamer.h"
Anton Korobeynikovc1874382008-07-19 13:14:46 +000020using namespace llvm;
21
Lang Hames1e923ec2015-01-09 18:55:42 +000022bool 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}
David Blaikiea379b1812011-12-20 02:50:00 +000069
Chris Lattner2b4364f2010-01-20 06:34:14 +000070MCAsmInfoDarwin::MCAsmInfoDarwin() {
Chris Lattner8284b662009-06-19 00:08:39 +000071 // Common settings for all Darwin targets.
72 // Syntax:
Tim Northover56276702014-03-29 07:33:24 +000073 LinkerPrivateGlobalPrefix = "l";
Chris Lattner8284b662009-06-19 00:08:39 +000074 HasSingleParameterDotFile = false;
Chris Lattner76bdea32010-01-23 07:21:06 +000075 HasSubsectionsViaSymbols = true;
Chris Lattner8284b662009-06-19 00:08:39 +000076
Chris Lattner54075a72009-08-11 22:31:42 +000077 AlignmentIsInBytes = false;
Rafael Espindoladcb03f02010-01-26 20:21:43 +000078 COMMDirectiveAlignmentIsInBytes = false;
Benjamin Kramer68b9f052012-09-07 21:08:01 +000079 LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
Chris Lattnerabdcbc72009-08-11 22:39:40 +000080 InlineAsmStart = " InlineAsm Start";
81 InlineAsmEnd = " InlineAsm End";
Chris Lattner54075a72009-08-11 22:31:42 +000082
Chris Lattner8284b662009-06-19 00:08:39 +000083 // Directives:
Rafael Espindola04867ce2013-12-02 23:04:51 +000084 HasWeakDefDirective = true;
David Fang1b018492013-12-10 21:37:41 +000085 HasWeakDefCanBeHiddenDirective = true;
Chris Lattner8284b662009-06-19 00:08:39 +000086 WeakRefDirective = "\t.weak_reference ";
Chris Lattnerd832c8e2009-08-11 22:17:31 +000087 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
Chris Lattner1d371882010-01-19 02:09:44 +000088 HasMachoZeroFillDirective = true; // Uses .zerofill
Eric Christopher27e7ffc2010-05-20 00:49:07 +000089 HasMachoTBSSDirective = true; // Uses .tbss
Chris Lattnere9d28b12010-01-19 04:34:02 +000090 HasStaticCtorDtorReferenceInStaticMode = true;
Rafael Espindola1048e752010-12-04 00:31:13 +000091
Rafael Espindolaa6cd2d82010-12-22 21:51:29 +000092 // FIXME: Change this once MC is the system assembler.
93 HasAggressiveSymbolFolding = false;
94
Chris Lattner0bfd2792010-01-23 06:53:23 +000095 HiddenVisibilityAttr = MCSA_PrivateExtern;
Stuart Hastingsbf836592011-02-23 02:27:05 +000096 HiddenDeclarationVisibilityAttr = MCSA_Invalid;
Bill Wendling11b98942011-11-29 02:39:58 +000097
Chris Lattner0bfd2792010-01-23 06:53:23 +000098 // Doesn't support protected visibility.
Bill Wendling11b98942011-11-29 02:39:58 +000099 ProtectedVisibilityAttr = MCSA_Invalid;
Jim Grosbachdc1e36e2012-05-11 01:41:30 +0000100
Chris Lattner54075a72009-08-11 22:31:42 +0000101 HasDotTypeDotSizeDirective = false;
Chris Lattner1deb09c2010-01-23 05:51:36 +0000102 HasNoDeadStrip = true;
Devang Patelea636392010-08-31 23:50:19 +0000103
Nick Lewycky33da3362012-06-22 01:25:12 +0000104 DwarfUsesRelocationsAcrossSections = false;
Daniel Sanders753e1762014-02-13 14:44:26 +0000105
106 UseIntegratedAssembler = true;
Rafael Espindolac606bfe2014-10-21 01:17:30 +0000107 SetDirectiveSuppressesReloc = true;
Anton Korobeynikovc1874382008-07-19 13:14:46 +0000108}