1 //===-- ARM64MCAsmInfo.cpp - ARM64 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 ARM64MCAsmInfo properties.
12 //===----------------------------------------------------------------------===//
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"
21 enum AsmWriterVariantTy {
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"),
34 ARM64MCAsmInfoDarwin::ARM64MCAsmInfoDarwin() {
35 // We prefer NEON instructions to be printed in the short form.
36 AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
38 PrivateGlobalPrefix = "L";
39 SeparatorString = "%%";
41 PointerSize = CalleeSaveStackSlotSize = 8;
43 AlignmentIsInBytes = false;
44 UsesELFSectionDirectiveForBSS = true;
45 SupportsDebugInformation = true;
46 UseDataRegionDirectives = true;
48 ExceptionsType = ExceptionHandling::DwarfCFI;
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
57 MCContext &Context = Streamer.getContext();
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);
66 ARM64MCAsmInfoELF::ARM64MCAsmInfoELF() {
67 // We prefer NEON instructions to be printed in the short form.
68 AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
72 // ".comm align is in bytes but .align is pow-2."
73 AlignmentIsInBytes = false;
76 PrivateGlobalPrefix = ".L";
77 Code32Directive = ".code\t32";
79 Data16bitsDirective = "\t.hword\t";
80 Data32bitsDirective = "\t.word\t";
81 Data64bitsDirective = "\t.xword\t";
83 UseDataRegionDirectives = false;
85 WeakRefDirective = "\t.weak\t";
88 SupportsDebugInformation = true;
90 // Exceptions handling
91 ExceptionsType = ExceptionHandling::DwarfCFI;