blob: 921c4b94a7299d313c38c123bdd1767b0caf2409 [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"
Daniel Sanders50f17232015-09-15 16:17:27 +000015#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 =
Jim Grosbach13760bd2015-05-30 01:25:56 +000065 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, Context);
Jim Grosbach6f482002015-05-18 18:43:14 +000066 MCSymbol *PCSym = Context.createTempSymbol();
Tim Northover3b0846e2014-05-24 12:50:23 +000067 Streamer.EmitLabel(PCSym);
Jim Grosbach13760bd2015-05-30 01:25:56 +000068 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
69 return MCBinaryExpr::createSub(Res, PC, Context);
Tim Northover3b0846e2014-05-24 12:50:23 +000070}
71
Daniel Sanders50f17232015-09-15 16:17:27 +000072AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
73 if (T.getArch() == Triple::aarch64_be)
Tim Northover3b0846e2014-05-24 12:50:23 +000074 IsLittleEndian = false;
75
76 // We prefer NEON instructions to be printed in the short form.
77 AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
78
79 PointerSize = 8;
80
81 // ".comm align is in bytes but .align is pow-2."
82 AlignmentIsInBytes = false;
83
84 CommentString = "//";
85 PrivateGlobalPrefix = ".L";
Matt Arsenault4e273432014-12-04 00:06:57 +000086 PrivateLabelPrefix = ".L";
Tim Northover3b0846e2014-05-24 12:50:23 +000087 Code32Directive = ".code\t32";
88
89 Data16bitsDirective = "\t.hword\t";
90 Data32bitsDirective = "\t.word\t";
91 Data64bitsDirective = "\t.xword\t";
92
93 UseDataRegionDirectives = false;
94
95 WeakRefDirective = "\t.weak\t";
96
Tim Northover3b0846e2014-05-24 12:50:23 +000097 SupportsDebugInformation = true;
98
99 // Exceptions handling
100 ExceptionsType = ExceptionHandling::DwarfCFI;
101
102 UseIntegratedAssembler = true;
Chad Rosierd863ae32014-06-10 14:32:08 +0000103
104 HasIdentDirective = true;
Tim Northover3b0846e2014-05-24 12:50:23 +0000105}