blob: c41220400410290a0e4f47056b3bb2785a27f319 [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001//===-- 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"
Tim Northover3b0846e2014-05-24 12:50:23 +000016#include "llvm/MC/MCContext.h"
Benjamin Kramer1f8930e2014-07-25 11:42:14 +000017#include "llvm/MC/MCExpr.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000018#include "llvm/MC/MCStreamer.h"
19#include "llvm/Support/CommandLine.h"
20using namespace llvm;
21
22enum AsmWriterVariantTy {
23 Default = -1,
24 Generic = 0,
25 Apple = 1
26};
27
28static 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
35AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() {
36 // We prefer NEON instructions to be printed in the short form.
37 AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
38
39 PrivateGlobalPrefix = "L";
Matt Arsenault4e273432014-12-04 00:06:57 +000040 PrivateLabelPrefix = "L";
Tim Northover3b0846e2014-05-24 12:50:23 +000041 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;
Ahmed Bougacha19052872015-04-28 01:37:11 +000051
52 // AArch64 Darwin doesn't have the baggage of X86/ARM, so it's fine to use
53 // LShr instead of AShr.
54 UseLogicalShr = true;
Tim Northover3b0846e2014-05-24 12:50:23 +000055}
56
57const 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
62 // version.
63 MCContext &Context = Streamer.getContext();
64 const MCExpr *Res =
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);
70}
71
72AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(StringRef TT) {
73 Triple T(TT);
Tim Northovere19bed72014-07-23 12:32:47 +000074 if (T.getArch() == Triple::aarch64_be)
Tim Northover3b0846e2014-05-24 12:50:23 +000075 IsLittleEndian = false;
76
77 // We prefer NEON instructions to be printed in the short form.
78 AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
79
80 PointerSize = 8;
81
82 // ".comm align is in bytes but .align is pow-2."
83 AlignmentIsInBytes = false;
84
85 CommentString = "//";
86 PrivateGlobalPrefix = ".L";
Matt Arsenault4e273432014-12-04 00:06:57 +000087 PrivateLabelPrefix = ".L";
Tim Northover3b0846e2014-05-24 12:50:23 +000088 Code32Directive = ".code\t32";
89
90 Data16bitsDirective = "\t.hword\t";
91 Data32bitsDirective = "\t.word\t";
92 Data64bitsDirective = "\t.xword\t";
93
94 UseDataRegionDirectives = false;
95
96 WeakRefDirective = "\t.weak\t";
97
Tim Northover3b0846e2014-05-24 12:50:23 +000098 SupportsDebugInformation = true;
99
100 // Exceptions handling
101 ExceptionsType = ExceptionHandling::DwarfCFI;
102
103 UseIntegratedAssembler = true;
Chad Rosierd863ae32014-06-10 14:32:08 +0000104
105 HasIdentDirective = true;
Tim Northover3b0846e2014-05-24 12:50:23 +0000106}