1 //===-- AArch64MCAsmInfo.cpp - AArch64 asm properties ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declarations of the AArch64MCAsmInfo properties.
12 //===----------------------------------------------------------------------===//
14 #include "AArch64MCAsmInfo.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCStreamer.h"
19 #include "llvm/Support/CommandLine.h"
22 enum AsmWriterVariantTy {
28 static cl::opt<AsmWriterVariantTy> AsmWriterVariant(
29 "aarch64-neon-syntax", cl::init(Default),
30 cl::desc("Choose style of NEON code to emit from AArch64 backend:"),
31 cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"),
32 clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly")));
34 AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() {
35 // We prefer NEON instructions to be printed in the short, Apple-specific
36 // form when targeting Darwin.
37 AssemblerDialect = AsmWriterVariant == Default ? Apple : AsmWriterVariant;
39 PrivateGlobalPrefix = "L";
40 PrivateLabelPrefix = "L";
41 SeparatorString = "%%";
43 CodePointerSize = CalleeSaveStackSlotSize = 8;
45 AlignmentIsInBytes = false;
46 UsesELFSectionDirectiveForBSS = true;
47 SupportsDebugInformation = true;
48 UseDataRegionDirectives = true;
50 ExceptionsType = ExceptionHandling::DwarfCFI;
53 const MCExpr *AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol(
54 const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
55 // On Darwin, we can reference dwarf symbols with foo@GOT-., which
56 // is an indirect pc-relative reference. The default implementation
57 // won't reference using the GOT, so we need this target-specific
59 MCContext &Context = Streamer.getContext();
61 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, Context);
62 MCSymbol *PCSym = Context.createTempSymbol();
63 Streamer.EmitLabel(PCSym);
64 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
65 return MCBinaryExpr::createSub(Res, PC, Context);
68 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
69 if (T.getArch() == Triple::aarch64_be)
70 IsLittleEndian = false;
72 // We prefer NEON instructions to be printed in the generic form when
74 AssemblerDialect = AsmWriterVariant == Default ? Generic : AsmWriterVariant;
78 // ".comm align is in bytes but .align is pow-2."
79 AlignmentIsInBytes = false;
82 PrivateGlobalPrefix = ".L";
83 PrivateLabelPrefix = ".L";
84 Code32Directive = ".code\t32";
86 Data16bitsDirective = "\t.hword\t";
87 Data32bitsDirective = "\t.word\t";
88 Data64bitsDirective = "\t.xword\t";
90 UseDataRegionDirectives = false;
92 WeakRefDirective = "\t.weak\t";
94 SupportsDebugInformation = true;
96 // Exceptions handling
97 ExceptionsType = ExceptionHandling::DwarfCFI;
99 UseIntegratedAssembler = true;
101 HasIdentDirective = true;
104 AArch64MCAsmInfoMicrosoftCOFF::AArch64MCAsmInfoMicrosoftCOFF() {
105 PrivateGlobalPrefix = ".L";
106 PrivateLabelPrefix = ".L";
108 Data16bitsDirective = "\t.hword\t";
109 Data32bitsDirective = "\t.word\t";
110 Data64bitsDirective = "\t.xword\t";
112 AlignmentIsInBytes = false;
113 SupportsDebugInformation = true;
117 ExceptionsType = ExceptionHandling::WinEH;
118 WinEHEncodingType = WinEH::EncodingType::Itanium;
121 AArch64MCAsmInfoGNUCOFF::AArch64MCAsmInfoGNUCOFF() {
122 PrivateGlobalPrefix = ".L";
123 PrivateLabelPrefix = ".L";
125 Data16bitsDirective = "\t.hword\t";
126 Data32bitsDirective = "\t.word\t";
127 Data64bitsDirective = "\t.xword\t";
129 AlignmentIsInBytes = false;
130 SupportsDebugInformation = true;
133 CommentString = "//";
134 ExceptionsType = ExceptionHandling::DwarfCFI;
135 // The default is dwarf, but WinEH can be enabled optionally, which requires
136 // WinEHEncodingType to be set.
137 WinEHEncodingType = WinEH::EncodingType::Itanium;