AArch64MCAsmInfo.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //===-- AArch64MCAsmInfo.cpp - AArch64 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 contains the declarations of the AArch64MCAsmInfo properties.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "AArch64MCAsmInfo.h"
  13. #include "llvm/ADT/Triple.h"
  14. #include "llvm/MC/MCContext.h"
  15. #include "llvm/MC/MCExpr.h"
  16. #include "llvm/MC/MCStreamer.h"
  17. #include "llvm/Support/CommandLine.h"
  18. using namespace llvm;
  19. enum AsmWriterVariantTy {
  20. Default = -1,
  21. Generic = 0,
  22. Apple = 1
  23. };
  24. static cl::opt<AsmWriterVariantTy> AsmWriterVariant(
  25. "aarch64-neon-syntax", cl::init(Default),
  26. cl::desc("Choose style of NEON code to emit from AArch64 backend:"),
  27. cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"),
  28. clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly")));
  29. AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin(bool IsILP32) {
  30. // We prefer NEON instructions to be printed in the short, Apple-specific
  31. // form when targeting Darwin.
  32. AssemblerDialect = AsmWriterVariant == Default ? Apple : AsmWriterVariant;
  33. PrivateGlobalPrefix = "L";
  34. PrivateLabelPrefix = "L";
  35. SeparatorString = "%%";
  36. CommentString = ";";
  37. CalleeSaveStackSlotSize = 8;
  38. CodePointerSize = IsILP32 ? 4 : 8;
  39. AlignmentIsInBytes = false;
  40. UsesELFSectionDirectiveForBSS = true;
  41. SupportsDebugInformation = true;
  42. UseDataRegionDirectives = true;
  43. ExceptionsType = ExceptionHandling::DwarfCFI;
  44. }
  45. const MCExpr *AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol(
  46. const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
  47. // On Darwin, we can reference dwarf symbols with foo@GOT-., which
  48. // is an indirect pc-relative reference. The default implementation
  49. // won't reference using the GOT, so we need this target-specific
  50. // version.
  51. MCContext &Context = Streamer.getContext();
  52. const MCExpr *Res =
  53. MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, Context);
  54. MCSymbol *PCSym = Context.createTempSymbol();
  55. Streamer.emitLabel(PCSym);
  56. const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
  57. return MCBinaryExpr::createSub(Res, PC, Context);
  58. }
  59. AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
  60. if (T.getArch() == Triple::aarch64_be)
  61. IsLittleEndian = false;
  62. // We prefer NEON instructions to be printed in the generic form when
  63. // targeting ELF.
  64. AssemblerDialect = AsmWriterVariant == Default ? Generic : AsmWriterVariant;
  65. CodePointerSize = T.getEnvironment() == Triple::GNUILP32 ? 4 : 8;
  66. // ".comm align is in bytes but .align is pow-2."
  67. AlignmentIsInBytes = false;
  68. CommentString = "//";
  69. PrivateGlobalPrefix = ".L";
  70. PrivateLabelPrefix = ".L";
  71. Code32Directive = ".code\t32";
  72. Data16bitsDirective = "\t.hword\t";
  73. Data32bitsDirective = "\t.word\t";
  74. Data64bitsDirective = "\t.xword\t";
  75. UseDataRegionDirectives = false;
  76. WeakRefDirective = "\t.weak\t";
  77. SupportsDebugInformation = true;
  78. // Exceptions handling
  79. ExceptionsType = ExceptionHandling::DwarfCFI;
  80. HasIdentDirective = true;
  81. }
  82. AArch64MCAsmInfoMicrosoftCOFF::AArch64MCAsmInfoMicrosoftCOFF() {
  83. PrivateGlobalPrefix = ".L";
  84. PrivateLabelPrefix = ".L";
  85. Data16bitsDirective = "\t.hword\t";
  86. Data32bitsDirective = "\t.word\t";
  87. Data64bitsDirective = "\t.xword\t";
  88. AlignmentIsInBytes = false;
  89. SupportsDebugInformation = true;
  90. CodePointerSize = 8;
  91. CommentString = "//";
  92. ExceptionsType = ExceptionHandling::WinEH;
  93. WinEHEncodingType = WinEH::EncodingType::Itanium;
  94. }
  95. AArch64MCAsmInfoGNUCOFF::AArch64MCAsmInfoGNUCOFF() {
  96. PrivateGlobalPrefix = ".L";
  97. PrivateLabelPrefix = ".L";
  98. Data16bitsDirective = "\t.hword\t";
  99. Data32bitsDirective = "\t.word\t";
  100. Data64bitsDirective = "\t.xword\t";
  101. AlignmentIsInBytes = false;
  102. SupportsDebugInformation = true;
  103. CodePointerSize = 8;
  104. CommentString = "//";
  105. ExceptionsType = ExceptionHandling::WinEH;
  106. WinEHEncodingType = WinEH::EncodingType::Itanium;
  107. }