blob: c74840982fb75d19fae52b492531ed6f4601f82a [file] [log] [blame]
Eugene Zelenkoa700a602017-02-11 00:27:28 +00001//===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===//
Anton Korobeynikov745e8642008-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 Lattneraf76e592009-08-22 20:48:53 +000015#include "llvm/MC/MCAsmInfoDarwin.h"
Zachary Turner19ca2b02017-06-07 03:48:56 +000016#include "llvm/BinaryFormat/MachO.h"
Eugene Zelenkoa700a602017-02-11 00:27:28 +000017#include "llvm/MC/MCDirectives.h"
Lang Hames4c553e02015-01-09 18:55:42 +000018#include "llvm/MC/MCSectionMachO.h"
Eugene Zelenkoa700a602017-02-11 00:27:28 +000019
Anton Korobeynikov745e8642008-07-19 13:14:46 +000020using namespace llvm;
21
Lang Hames4c553e02015-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.
Rafael Espindolaa23cc6a2015-01-19 21:11:14 +000030 if (SMO.getType() == MachO::S_CSTRING_LITERALS)
Lang Hames4c553e02015-01-09 18:55:42 +000031 return false;
32
33 if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
34 return false;
35
Rafael Espindolaef1d2262015-02-12 23:11:59 +000036 if (SMO.getSegmentName() == "__DATA" &&
37 SMO.getSectionName() == "__objc_classrefs")
38 return false;
39
Lang Hames4c553e02015-01-09 18:55:42 +000040 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:
Tim Northover02e44982016-04-25 21:12:04 +000052 case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS:
Lang Hames4c553e02015-01-09 18:55:42 +000053 case MachO::S_MOD_INIT_FUNC_POINTERS:
54 case MachO::S_MOD_TERM_FUNC_POINTERS:
55 case MachO::S_INTERPOSING:
56 return false;
57 }
58}
David Blaikie2d24e2a2011-12-20 02:50:00 +000059
Chris Lattner8eeba352010-01-20 06:34:14 +000060MCAsmInfoDarwin::MCAsmInfoDarwin() {
Chris Lattner4e0f25b2009-06-19 00:08:39 +000061 // Common settings for all Darwin targets.
62 // Syntax:
Tim Northover03011542014-03-29 07:33:24 +000063 LinkerPrivateGlobalPrefix = "l";
Chris Lattner4e0f25b2009-06-19 00:08:39 +000064 HasSingleParameterDotFile = false;
Chris Lattnerf9f93e42010-01-23 07:21:06 +000065 HasSubsectionsViaSymbols = true;
Chris Lattner4e0f25b2009-06-19 00:08:39 +000066
Chris Lattnere28a2e82009-08-11 22:31:42 +000067 AlignmentIsInBytes = false;
Rafael Espindola2e2563b2010-01-26 20:21:43 +000068 COMMDirectiveAlignmentIsInBytes = false;
Benjamin Kramera9e37c52012-09-07 21:08:01 +000069 LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
Chris Lattnere2b06012009-08-11 22:39:40 +000070 InlineAsmStart = " InlineAsm Start";
71 InlineAsmEnd = " InlineAsm End";
Chris Lattnere28a2e82009-08-11 22:31:42 +000072
Chris Lattner4e0f25b2009-06-19 00:08:39 +000073 // Directives:
Rafael Espindola29a0d2a2013-12-02 23:04:51 +000074 HasWeakDefDirective = true;
David Fangb59d46e2013-12-10 21:37:41 +000075 HasWeakDefCanBeHiddenDirective = true;
Chris Lattner4e0f25b2009-06-19 00:08:39 +000076 WeakRefDirective = "\t.weak_reference ";
Chris Lattnerb6ba9c32009-08-11 22:17:31 +000077 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
Chris Lattneraac138e2010-01-19 02:09:44 +000078 HasMachoZeroFillDirective = true; // Uses .zerofill
Eric Christopherc1a887d2010-05-20 00:49:07 +000079 HasMachoTBSSDirective = true; // Uses .tbss
Rafael Espindola767b1be2010-12-04 00:31:13 +000080
Rafael Espindola90a5a0c2010-12-22 21:51:29 +000081 // FIXME: Change this once MC is the system assembler.
82 HasAggressiveSymbolFolding = false;
83
Chris Lattner152a29b2010-01-23 06:53:23 +000084 HiddenVisibilityAttr = MCSA_PrivateExtern;
Stuart Hastings5129bde2011-02-23 02:27:05 +000085 HiddenDeclarationVisibilityAttr = MCSA_Invalid;
Bill Wendling6ea04672011-11-29 02:39:58 +000086
Chris Lattner152a29b2010-01-23 06:53:23 +000087 // Doesn't support protected visibility.
Bill Wendling6ea04672011-11-29 02:39:58 +000088 ProtectedVisibilityAttr = MCSA_Invalid;
Jim Grosbach2684d9e2012-05-11 01:41:30 +000089
Chris Lattnere28a2e82009-08-11 22:31:42 +000090 HasDotTypeDotSizeDirective = false;
Chris Lattner3a9be0e2010-01-23 05:51:36 +000091 HasNoDeadStrip = true;
Lang Hames875b7562016-03-15 01:43:05 +000092 HasAltEntry = true;
Devang Patelae84d5b2010-08-31 23:50:19 +000093
Nick Lewyckyffccd922012-06-22 01:25:12 +000094 DwarfUsesRelocationsAcrossSections = false;
Daniel Sanders38c6b582014-02-13 14:44:26 +000095
96 UseIntegratedAssembler = true;
Rafael Espindola45968c52014-10-21 01:17:30 +000097 SetDirectiveSuppressesReloc = true;
Anton Korobeynikov745e8642008-07-19 13:14:46 +000098}