[ARM64] Move ARM64BaseInfo.{cpp,h} into a Utils/ subdirectory, a la AArch64. These...
[oota-llvm.git] / lib / Target / ARM64 / MCTargetDesc / ARM64MCAsmInfo.cpp
1 //===-- ARM64MCAsmInfo.cpp - ARM64 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 ARM64MCAsmInfo properties.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "ARM64MCAsmInfo.h"
15 #include "llvm/MC/MCExpr.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCStreamer.h"
18 #include "llvm/Support/CommandLine.h"
19 using namespace llvm;
20
21 enum AsmWriterVariantTy {
22   Default = -1,
23   Generic = 0,
24   Apple = 1
25 };
26
27 static cl::opt<AsmWriterVariantTy> AsmWriterVariant(
28     "arm64-neon-syntax", cl::init(Default),
29     cl::desc("Choose style of NEON code to emit from ARM64 backend:"),
30     cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"),
31                clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly"),
32                clEnumValEnd));
33
34 ARM64MCAsmInfoDarwin::ARM64MCAsmInfoDarwin() {
35   // We prefer NEON instructions to be printed in the short form.
36   AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
37
38   PrivateGlobalPrefix = "L";
39   SeparatorString = "%%";
40   CommentString = ";";
41   PointerSize = CalleeSaveStackSlotSize = 8;
42
43   AlignmentIsInBytes = false;
44   UsesELFSectionDirectiveForBSS = true;
45   SupportsDebugInformation = true;
46   UseDataRegionDirectives = true;
47
48   ExceptionsType = ExceptionHandling::DwarfCFI;
49 }
50
51 const MCExpr *ARM64MCAsmInfoDarwin::getExprForPersonalitySymbol(
52     const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
53   // On Darwin, we can reference dwarf symbols with foo@GOT-., which
54   // is an indirect pc-relative reference. The default implementation
55   // won't reference using the GOT, so we need this target-specific
56   // version.
57   MCContext &Context = Streamer.getContext();
58   const MCExpr *Res =
59       MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOT, Context);
60   MCSymbol *PCSym = Context.CreateTempSymbol();
61   Streamer.EmitLabel(PCSym);
62   const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
63   return MCBinaryExpr::CreateSub(Res, PC, Context);
64 }
65
66 ARM64MCAsmInfoELF::ARM64MCAsmInfoELF() {
67   // We prefer NEON instructions to be printed in the short form.
68   AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
69
70   PointerSize = 8;
71
72   // ".comm align is in bytes but .align is pow-2."
73   AlignmentIsInBytes = false;
74
75   CommentString = "//";
76   PrivateGlobalPrefix = ".L";
77   Code32Directive = ".code\t32";
78
79   Data16bitsDirective = "\t.hword\t";
80   Data32bitsDirective = "\t.word\t";
81   Data64bitsDirective = "\t.xword\t";
82
83   UseDataRegionDirectives = false;
84
85   WeakRefDirective = "\t.weak\t";
86
87   HasLEB128 = true;
88   SupportsDebugInformation = true;
89
90   // Exceptions handling
91   ExceptionsType = ExceptionHandling::DwarfCFI;
92 }