Chris Lattner | 7b26fce | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 1 | //===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===// |
Anton Korobeynikov | c187438 | 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 | 7b26fce | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 15 | #include "llvm/MC/MCAsmInfoDarwin.h" |
Rafael Espindola | c5dac4d | 2011-04-28 16:09:09 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCContext.h" |
| 17 | #include "llvm/MC/MCExpr.h" |
Lang Hames | 1e923ec | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCSectionMachO.h" |
Anton Korobeynikov | c187438 | 2008-07-19 13:14:46 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | |
Lang Hames | 1e923ec | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 21 | bool MCAsmInfoDarwin::isSectionAtomizableBySymbols( |
| 22 | const MCSection &Section) const { |
| 23 | const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section); |
| 24 | |
| 25 | // Sections holding 1 byte strings are atomized based on the data they |
| 26 | // contain. |
| 27 | // Sections holding 2 byte strings require symbols in order to be atomized. |
| 28 | // There is no dedicated section for 4 byte strings. |
Rafael Espindola | 2658554 | 2015-01-19 21:11:14 +0000 | [diff] [blame] | 29 | if (SMO.getType() == MachO::S_CSTRING_LITERALS) |
Lang Hames | 1e923ec | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 30 | return false; |
| 31 | |
| 32 | if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring") |
| 33 | return false; |
| 34 | |
Rafael Espindola | e4bcad4 | 2015-02-12 23:11:59 +0000 | [diff] [blame] | 35 | if (SMO.getSegmentName() == "__DATA" && |
| 36 | SMO.getSectionName() == "__objc_classrefs") |
| 37 | return false; |
| 38 | |
Lang Hames | 1e923ec | 2015-01-09 18:55:42 +0000 | [diff] [blame] | 39 | switch (SMO.getType()) { |
| 40 | default: |
| 41 | return true; |
| 42 | |
| 43 | // These sections are atomized at the element boundaries without using |
| 44 | // symbols. |
| 45 | case MachO::S_4BYTE_LITERALS: |
| 46 | case MachO::S_8BYTE_LITERALS: |
| 47 | case MachO::S_16BYTE_LITERALS: |
| 48 | case MachO::S_LITERAL_POINTERS: |
| 49 | case MachO::S_NON_LAZY_SYMBOL_POINTERS: |
| 50 | case MachO::S_LAZY_SYMBOL_POINTERS: |
| 51 | case MachO::S_MOD_INIT_FUNC_POINTERS: |
| 52 | case MachO::S_MOD_TERM_FUNC_POINTERS: |
| 53 | case MachO::S_INTERPOSING: |
| 54 | return false; |
| 55 | } |
| 56 | } |
David Blaikie | a379b181 | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 57 | |
Chris Lattner | 2b4364f | 2010-01-20 06:34:14 +0000 | [diff] [blame] | 58 | MCAsmInfoDarwin::MCAsmInfoDarwin() { |
Chris Lattner | 8284b66 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 59 | // Common settings for all Darwin targets. |
| 60 | // Syntax: |
Tim Northover | 5627670 | 2014-03-29 07:33:24 +0000 | [diff] [blame] | 61 | LinkerPrivateGlobalPrefix = "l"; |
Chris Lattner | 8284b66 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 62 | HasSingleParameterDotFile = false; |
Chris Lattner | 76bdea3 | 2010-01-23 07:21:06 +0000 | [diff] [blame] | 63 | HasSubsectionsViaSymbols = true; |
Chris Lattner | 8284b66 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 64 | |
Chris Lattner | 54075a7 | 2009-08-11 22:31:42 +0000 | [diff] [blame] | 65 | AlignmentIsInBytes = false; |
Rafael Espindola | dcb03f0 | 2010-01-26 20:21:43 +0000 | [diff] [blame] | 66 | COMMDirectiveAlignmentIsInBytes = false; |
Benjamin Kramer | 68b9f05 | 2012-09-07 21:08:01 +0000 | [diff] [blame] | 67 | LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment; |
Chris Lattner | abdcbc7 | 2009-08-11 22:39:40 +0000 | [diff] [blame] | 68 | InlineAsmStart = " InlineAsm Start"; |
| 69 | InlineAsmEnd = " InlineAsm End"; |
Chris Lattner | 54075a7 | 2009-08-11 22:31:42 +0000 | [diff] [blame] | 70 | |
Chris Lattner | 8284b66 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 71 | // Directives: |
Rafael Espindola | 04867ce | 2013-12-02 23:04:51 +0000 | [diff] [blame] | 72 | HasWeakDefDirective = true; |
David Fang | 1b01849 | 2013-12-10 21:37:41 +0000 | [diff] [blame] | 73 | HasWeakDefCanBeHiddenDirective = true; |
Chris Lattner | 8284b66 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 74 | WeakRefDirective = "\t.weak_reference "; |
Chris Lattner | d832c8e | 2009-08-11 22:17:31 +0000 | [diff] [blame] | 75 | ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. |
Chris Lattner | 1d37188 | 2010-01-19 02:09:44 +0000 | [diff] [blame] | 76 | HasMachoZeroFillDirective = true; // Uses .zerofill |
Eric Christopher | 27e7ffc | 2010-05-20 00:49:07 +0000 | [diff] [blame] | 77 | HasMachoTBSSDirective = true; // Uses .tbss |
Chris Lattner | e9d28b1 | 2010-01-19 04:34:02 +0000 | [diff] [blame] | 78 | HasStaticCtorDtorReferenceInStaticMode = true; |
Rafael Espindola | 1048e75 | 2010-12-04 00:31:13 +0000 | [diff] [blame] | 79 | |
Rafael Espindola | a6cd2d8 | 2010-12-22 21:51:29 +0000 | [diff] [blame] | 80 | // FIXME: Change this once MC is the system assembler. |
| 81 | HasAggressiveSymbolFolding = false; |
| 82 | |
Chris Lattner | 0bfd279 | 2010-01-23 06:53:23 +0000 | [diff] [blame] | 83 | HiddenVisibilityAttr = MCSA_PrivateExtern; |
Stuart Hastings | bf83659 | 2011-02-23 02:27:05 +0000 | [diff] [blame] | 84 | HiddenDeclarationVisibilityAttr = MCSA_Invalid; |
Bill Wendling | 11b9894 | 2011-11-29 02:39:58 +0000 | [diff] [blame] | 85 | |
Chris Lattner | 0bfd279 | 2010-01-23 06:53:23 +0000 | [diff] [blame] | 86 | // Doesn't support protected visibility. |
Bill Wendling | 11b9894 | 2011-11-29 02:39:58 +0000 | [diff] [blame] | 87 | ProtectedVisibilityAttr = MCSA_Invalid; |
Jim Grosbach | dc1e36e | 2012-05-11 01:41:30 +0000 | [diff] [blame] | 88 | |
Chris Lattner | 54075a7 | 2009-08-11 22:31:42 +0000 | [diff] [blame] | 89 | HasDotTypeDotSizeDirective = false; |
Chris Lattner | 1deb09c | 2010-01-23 05:51:36 +0000 | [diff] [blame] | 90 | HasNoDeadStrip = true; |
Devang Patel | ea63639 | 2010-08-31 23:50:19 +0000 | [diff] [blame] | 91 | |
Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 92 | DwarfUsesRelocationsAcrossSections = false; |
Daniel Sanders | 753e176 | 2014-02-13 14:44:26 +0000 | [diff] [blame] | 93 | |
| 94 | UseIntegratedAssembler = true; |
Rafael Espindola | c606bfe | 2014-10-21 01:17:30 +0000 | [diff] [blame] | 95 | SetDirectiveSuppressesReloc = true; |
Ahmed Bougacha | 1905287 | 2015-04-28 01:37:11 +0000 | [diff] [blame] | 96 | |
| 97 | // FIXME: For now keep the previous behavior, AShr, matching the previous |
| 98 | // behavior of as(1) (both -q and -Q: resp. LLVM and gas v1.38). |
| 99 | // If/when this changes, the AArch64 Darwin special case can go away. |
| 100 | UseLogicalShr = false; |
Anton Korobeynikov | c187438 | 2008-07-19 13:14:46 +0000 | [diff] [blame] | 101 | } |