MCAsmInfoDarwin.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //===-- MCAsmInfoDarwin.cpp - Darwin asm properties -------------*- C++ -*-===//
  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. #include "llvm/MC/MCAsmInfoDarwin.h"
  15. #include "llvm/MC/MCContext.h"
  16. #include "llvm/MC/MCExpr.h"
  17. #include "llvm/MC/MCSectionMachO.h"
  18. using namespace llvm;
  19. bool MCAsmInfoDarwin::isSectionAtomizableBySymbols(
  20. const MCSection &Section) const {
  21. const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
  22. // Sections holding 1 byte strings are atomized based on the data they
  23. // contain.
  24. // Sections holding 2 byte strings require symbols in order to be atomized.
  25. // There is no dedicated section for 4 byte strings.
  26. if (SMO.getType() == MachO::S_CSTRING_LITERALS)
  27. return false;
  28. if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
  29. return false;
  30. if (SMO.getSegmentName() == "__DATA" &&
  31. SMO.getSectionName() == "__objc_classrefs")
  32. return false;
  33. switch (SMO.getType()) {
  34. default:
  35. return true;
  36. // These sections are atomized at the element boundaries without using
  37. // symbols.
  38. case MachO::S_4BYTE_LITERALS:
  39. case MachO::S_8BYTE_LITERALS:
  40. case MachO::S_16BYTE_LITERALS:
  41. case MachO::S_LITERAL_POINTERS:
  42. case MachO::S_NON_LAZY_SYMBOL_POINTERS:
  43. case MachO::S_LAZY_SYMBOL_POINTERS:
  44. case MachO::S_MOD_INIT_FUNC_POINTERS:
  45. case MachO::S_MOD_TERM_FUNC_POINTERS:
  46. case MachO::S_INTERPOSING:
  47. return false;
  48. }
  49. }
  50. MCAsmInfoDarwin::MCAsmInfoDarwin() {
  51. // Common settings for all Darwin targets.
  52. // Syntax:
  53. LinkerPrivateGlobalPrefix = "l";
  54. HasSingleParameterDotFile = false;
  55. HasSubsectionsViaSymbols = true;
  56. AlignmentIsInBytes = false;
  57. COMMDirectiveAlignmentIsInBytes = false;
  58. LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
  59. InlineAsmStart = " InlineAsm Start";
  60. InlineAsmEnd = " InlineAsm End";
  61. // Directives:
  62. HasWeakDefDirective = true;
  63. HasWeakDefCanBeHiddenDirective = true;
  64. WeakRefDirective = "\t.weak_reference ";
  65. ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
  66. HasMachoZeroFillDirective = true; // Uses .zerofill
  67. HasMachoTBSSDirective = true; // Uses .tbss
  68. HasStaticCtorDtorReferenceInStaticMode = true;
  69. // FIXME: Change this once MC is the system assembler.
  70. HasAggressiveSymbolFolding = false;
  71. HiddenVisibilityAttr = MCSA_PrivateExtern;
  72. HiddenDeclarationVisibilityAttr = MCSA_Invalid;
  73. // Doesn't support protected visibility.
  74. ProtectedVisibilityAttr = MCSA_Invalid;
  75. HasDotTypeDotSizeDirective = false;
  76. HasNoDeadStrip = true;
  77. DwarfUsesRelocationsAcrossSections = false;
  78. UseIntegratedAssembler = true;
  79. SetDirectiveSuppressesReloc = true;
  80. // FIXME: For now keep the previous behavior, AShr, matching the previous
  81. // behavior of as(1) (both -q and -Q: resp. LLVM and gas v1.38).
  82. // If/when this changes, the AArch64 Darwin special case can go away.
  83. UseLogicalShr = false;
  84. }