Eugene Zelenko | a700a60 | 2017-02-11 00:27:28 +0000 | [diff] [blame] | 1 | //===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===// |
Anton Korobeynikov | 745e864 | 2008-07-19 13:14:46 +0000 | [diff] [blame] | 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 | |
Chris Lattner | af76e59 | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 15 | #include "llvm/MC/MCAsmInfoDarwin.h" |
Zachary Turner | 19ca2b0 | 2017-06-07 03:48:56 +0000 | [diff] [blame] | 16 | #include "llvm/BinaryFormat/MachO.h" |
Eugene Zelenko | a700a60 | 2017-02-11 00:27:28 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCDirectives.h" |
Lang Hames | 4c553e0 | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCSectionMachO.h" |
Eugene Zelenko | a700a60 | 2017-02-11 00:27:28 +0000 | [diff] [blame] | 19 | |
Anton Korobeynikov | 745e864 | 2008-07-19 13:14:46 +0000 | [diff] [blame] | 20 | using namespace llvm; |
| 21 | |
Lang Hames | 4c553e0 | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 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. |
Rafael Espindola | a23cc6a | 2015-01-19 21:11:14 +0000 | [diff] [blame] | 30 | if (SMO.getType() == MachO::S_CSTRING_LITERALS) |
Lang Hames | 4c553e0 | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 31 | return false; |
| 32 | |
| 33 | if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring") |
| 34 | return false; |
| 35 | |
Rafael Espindola | ef1d226 | 2015-02-12 23:11:59 +0000 | [diff] [blame] | 36 | if (SMO.getSegmentName() == "__DATA" && |
| 37 | SMO.getSectionName() == "__objc_classrefs") |
| 38 | return false; |
| 39 | |
Lang Hames | 4c553e0 | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 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: |
Tim Northover | 02e4498 | 2016-04-25 21:12:04 +0000 | [diff] [blame] | 52 | case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS: |
Lang Hames | 4c553e0 | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 53 | 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 Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 59 | |
Chris Lattner | 8eeba35 | 2010-01-20 06:34:14 +0000 | [diff] [blame] | 60 | MCAsmInfoDarwin::MCAsmInfoDarwin() { |
Chris Lattner | 4e0f25b | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 61 | // Common settings for all Darwin targets. |
| 62 | // Syntax: |
Tim Northover | 0301154 | 2014-03-29 07:33:24 +0000 | [diff] [blame] | 63 | LinkerPrivateGlobalPrefix = "l"; |
Chris Lattner | 4e0f25b | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 64 | HasSingleParameterDotFile = false; |
Chris Lattner | f9f93e4 | 2010-01-23 07:21:06 +0000 | [diff] [blame] | 65 | HasSubsectionsViaSymbols = true; |
Chris Lattner | 4e0f25b | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 66 | |
Chris Lattner | e28a2e8 | 2009-08-11 22:31:42 +0000 | [diff] [blame] | 67 | AlignmentIsInBytes = false; |
Rafael Espindola | 2e2563b | 2010-01-26 20:21:43 +0000 | [diff] [blame] | 68 | COMMDirectiveAlignmentIsInBytes = false; |
Benjamin Kramer | a9e37c5 | 2012-09-07 21:08:01 +0000 | [diff] [blame] | 69 | LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment; |
Chris Lattner | e2b0601 | 2009-08-11 22:39:40 +0000 | [diff] [blame] | 70 | InlineAsmStart = " InlineAsm Start"; |
| 71 | InlineAsmEnd = " InlineAsm End"; |
Chris Lattner | e28a2e8 | 2009-08-11 22:31:42 +0000 | [diff] [blame] | 72 | |
Chris Lattner | 4e0f25b | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 73 | // Directives: |
Rafael Espindola | 29a0d2a | 2013-12-02 23:04:51 +0000 | [diff] [blame] | 74 | HasWeakDefDirective = true; |
David Fang | b59d46e | 2013-12-10 21:37:41 +0000 | [diff] [blame] | 75 | HasWeakDefCanBeHiddenDirective = true; |
Chris Lattner | 4e0f25b | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 76 | WeakRefDirective = "\t.weak_reference "; |
Chris Lattner | b6ba9c3 | 2009-08-11 22:17:31 +0000 | [diff] [blame] | 77 | ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. |
Chris Lattner | aac138e | 2010-01-19 02:09:44 +0000 | [diff] [blame] | 78 | HasMachoZeroFillDirective = true; // Uses .zerofill |
Eric Christopher | c1a887d | 2010-05-20 00:49:07 +0000 | [diff] [blame] | 79 | HasMachoTBSSDirective = true; // Uses .tbss |
Rafael Espindola | 767b1be | 2010-12-04 00:31:13 +0000 | [diff] [blame] | 80 | |
Rafael Espindola | 90a5a0c | 2010-12-22 21:51:29 +0000 | [diff] [blame] | 81 | // FIXME: Change this once MC is the system assembler. |
| 82 | HasAggressiveSymbolFolding = false; |
| 83 | |
Chris Lattner | 152a29b | 2010-01-23 06:53:23 +0000 | [diff] [blame] | 84 | HiddenVisibilityAttr = MCSA_PrivateExtern; |
Stuart Hastings | 5129bde | 2011-02-23 02:27:05 +0000 | [diff] [blame] | 85 | HiddenDeclarationVisibilityAttr = MCSA_Invalid; |
Bill Wendling | 6ea0467 | 2011-11-29 02:39:58 +0000 | [diff] [blame] | 86 | |
Chris Lattner | 152a29b | 2010-01-23 06:53:23 +0000 | [diff] [blame] | 87 | // Doesn't support protected visibility. |
Bill Wendling | 6ea0467 | 2011-11-29 02:39:58 +0000 | [diff] [blame] | 88 | ProtectedVisibilityAttr = MCSA_Invalid; |
Jim Grosbach | 2684d9e | 2012-05-11 01:41:30 +0000 | [diff] [blame] | 89 | |
Chris Lattner | e28a2e8 | 2009-08-11 22:31:42 +0000 | [diff] [blame] | 90 | HasDotTypeDotSizeDirective = false; |
Chris Lattner | 3a9be0e | 2010-01-23 05:51:36 +0000 | [diff] [blame] | 91 | HasNoDeadStrip = true; |
Lang Hames | 875b756 | 2016-03-15 01:43:05 +0000 | [diff] [blame] | 92 | HasAltEntry = true; |
Devang Patel | ae84d5b | 2010-08-31 23:50:19 +0000 | [diff] [blame] | 93 | |
Nick Lewycky | ffccd92 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 94 | DwarfUsesRelocationsAcrossSections = false; |
Daniel Sanders | 38c6b58 | 2014-02-13 14:44:26 +0000 | [diff] [blame] | 95 | |
| 96 | UseIntegratedAssembler = true; |
Rafael Espindola | 45968c5 | 2014-10-21 01:17:30 +0000 | [diff] [blame] | 97 | SetDirectiveSuppressesReloc = true; |
Anton Korobeynikov | 745e864 | 2008-07-19 13:14:46 +0000 | [diff] [blame] | 98 | } |