1 //===-- AArch64MCAsmInfo.cpp - AArch64 asm properties ---------------------===//
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 contains the declarations of the AArch64MCAsmInfo properties.
11 //
12 //===----------------------------------------------------------------------===//
13 
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"
20 using namespace llvm;
21 
22 enum AsmWriterVariantTy {
23   Default = -1,
24   Generic = 0,
25   Apple = 1
26 };
27 
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"),
33                clEnumValEnd));
34 
AArch64MCAsmInfoDarwin()35 AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() {
36   // We prefer NEON instructions to be printed in the short form.
37   AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
38 
39   PrivateGlobalPrefix = "L";
40   PrivateLabelPrefix = "L";
41   SeparatorString = "%%";
42   CommentString = ";";
43   PointerSize = CalleeSaveStackSlotSize = 8;
44 
45   AlignmentIsInBytes = false;
46   UsesELFSectionDirectiveForBSS = true;
47   SupportsDebugInformation = true;
48   UseDataRegionDirectives = true;
49 
50   ExceptionsType = ExceptionHandling::DwarfCFI;
51 }
52 
getExprForPersonalitySymbol(const MCSymbol * Sym,unsigned Encoding,MCStreamer & Streamer) const53 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
58   // version.
59   MCContext &Context = Streamer.getContext();
60   const MCExpr *Res =
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);
66 }
67 
AArch64MCAsmInfoELF(StringRef TT)68 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(StringRef TT) {
69   Triple T(TT);
70   if (T.getArch() == Triple::aarch64_be)
71     IsLittleEndian = false;
72 
73   // We prefer NEON instructions to be printed in the short form.
74   AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
75 
76   PointerSize = 8;
77 
78   // ".comm align is in bytes but .align is pow-2."
79   AlignmentIsInBytes = false;
80 
81   CommentString = "//";
82   PrivateGlobalPrefix = ".L";
83   PrivateLabelPrefix = ".L";
84   Code32Directive = ".code\t32";
85 
86   Data16bitsDirective = "\t.hword\t";
87   Data32bitsDirective = "\t.word\t";
88   Data64bitsDirective = "\t.xword\t";
89 
90   UseDataRegionDirectives = false;
91 
92   WeakRefDirective = "\t.weak\t";
93 
94   SupportsDebugInformation = true;
95 
96   // Exceptions handling
97   ExceptionsType = ExceptionHandling::DwarfCFI;
98 
99   UseIntegratedAssembler = true;
100 
101   HasIdentDirective = true;
102 }
103