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"),
35 AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() {
36 // We prefer NEON instructions to be printed in the short form.
37 AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
39 PrivateGlobalPrefix = "L";
40 PrivateLabelPrefix = "L";
41 SeparatorString = "%%";
43 PointerSize = CalleeSaveStackSlotSize = 8;
45 AlignmentIsInBytes = false;
46 UsesELFSectionDirectiveForBSS = true;
47 SupportsDebugInformation = true;
48 UseDataRegionDirectives = true;
50 ExceptionsType = ExceptionHandling::DwarfCFI;
52 // AArch64 Darwin doesn't have the baggage of X86/ARM, so it's fine to use
53 // LShr instead of AShr.
57 const MCExpr *AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol(
58 const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
59 // On Darwin, we can reference dwarf symbols with foo@GOT-., which
60 // is an indirect pc-relative reference. The default implementation
61 // won't reference using the GOT, so we need this target-specific
63 MCContext &Context = Streamer.getContext();
65 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, Context);
66 MCSymbol *PCSym = Context.createTempSymbol();
67 Streamer.EmitLabel(PCSym);
68 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
69 return MCBinaryExpr::createSub(Res, PC, Context);
72 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
73 if (T.getArch() == Triple::aarch64_be)
74 IsLittleEndian = false;
76 // We prefer NEON instructions to be printed in the short form.
77 AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
81 // ".comm align is in bytes but .align is pow-2."
82 AlignmentIsInBytes = false;
85 PrivateGlobalPrefix = ".L";
86 PrivateLabelPrefix = ".L";
87 Code32Directive = ".code\t32";
89 Data16bitsDirective = "\t.hword\t";
90 Data32bitsDirective = "\t.word\t";
91 Data64bitsDirective = "\t.xword\t";
93 UseDataRegionDirectives = false;
95 WeakRefDirective = "\t.weak\t";
97 SupportsDebugInformation = true;
99 // Exceptions handling
100 ExceptionsType = ExceptionHandling::DwarfCFI;
102 UseIntegratedAssembler = true;
104 HasIdentDirective = true;