MCAsmInfoDarwin.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //===- MCAsmInfoDarwin.cpp - Darwin asm properties ------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file defines target asm properties related what form asm statements
  10. // should take in general on Darwin-based targets
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/MC/MCAsmInfoDarwin.h"
  14. #include "llvm/BinaryFormat/MachO.h"
  15. #include "llvm/MC/MCDirectives.h"
  16. #include "llvm/MC/MCSectionMachO.h"
  17. using namespace llvm;
  18. bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
  19. const MCSection &Section) const {
  20. const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
  21. // Sections holding 1 byte strings are atomized based on the data they
  22. // contain.
  23. // Sections holding 2 byte strings require symbols in order to be atomized.
  24. // There is no dedicated section for 4 byte strings.
  25. if (SMO.getType() == MachO::S_CSTRING_LITERALS)
  26. return false;
  27. if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__cfstring")
  28. return false;
  29. if (SMO.getSegmentName() == "__DATA" && SMO.getName() == "__objc_classrefs")
  30. return false;
  31. switch (SMO.getType()) {
  32. default:
  33. return true;
  34. // These sections are atomized at the element boundaries without using
  35. // symbols.
  36. case MachO::S_4BYTE_LITERALS:
  37. case MachO::S_8BYTE_LITERALS:
  38. case MachO::S_16BYTE_LITERALS:
  39. case MachO::S_LITERAL_POINTERS:
  40. case MachO::S_NON_LAZY_SYMBOL_POINTERS:
  41. case MachO::S_LAZY_SYMBOL_POINTERS:
  42. case MachO::S_THREAD_LOCAL_VARIABLE_POINTERS:
  43. case MachO::S_MOD_INIT_FUNC_POINTERS:
  44. case MachO::S_MOD_TERM_FUNC_POINTERS:
  45. case MachO::S_INTERPOSING:
  46. return false;
  47. }
  48. }
  49. MCAsmInfoDarwin::MCAsmInfoDarwin() {
  50. // Common settings for all Darwin targets.
  51. // Syntax:
  52. LinkerPrivateGlobalPrefix = "l";
  53. HasSingleParameterDotFile = false;
  54. HasSubsectionsViaSymbols = true;
  55. AlignmentIsInBytes = false;
  56. COMMDirectiveAlignmentIsInBytes = false;
  57. LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
  58. InlineAsmStart = " InlineAsm Start";
  59. InlineAsmEnd = " InlineAsm End";
  60. // Directives:
  61. HasWeakDefDirective = true;
  62. HasWeakDefCanBeHiddenDirective = true;
  63. WeakRefDirective = "\t.weak_reference ";
  64. ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
  65. HasMachoZeroFillDirective = true; // Uses .zerofill
  66. HasMachoTBSSDirective = true; // Uses .tbss
  67. // FIXME: Change this once MC is the system assembler.
  68. HasAggressiveSymbolFolding = false;
  69. HiddenVisibilityAttr = MCSA_PrivateExtern;
  70. HiddenDeclarationVisibilityAttr = MCSA_Invalid;
  71. // Doesn't support protected visibility.
  72. ProtectedVisibilityAttr = MCSA_Invalid;
  73. HasDotTypeDotSizeDirective = false;
  74. HasNoDeadStrip = true;
  75. HasAltEntry = true;
  76. DwarfUsesRelocationsAcrossSections = false;
  77. SetDirectiveSuppressesReloc = true;
  78. }