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/ADT/Triple.h"
16 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCContext.h"
18 #include "llvm/MC/MCStreamer.h"
19 #include "llvm/Support/CommandLine.h"
22 enum AsmWriterVariantTy {
28 static cl::opt<AsmWriterVariantTy> AsmWriterVariant(
29 "arm64-neon-syntax", cl::init(Default),
30 cl::desc("Choose style of NEON code to emit from ARM64 backend:"),
31 cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"),
32 clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly"),
35 ARM64MCAsmInfoDarwin::ARM64MCAsmInfoDarwin() {
36 // We prefer NEON instructions to be printed in the short form.
37 AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
39 PrivateGlobalPrefix = "L";
40 SeparatorString = "%%";
42 PointerSize = CalleeSaveStackSlotSize = 8;
44 AlignmentIsInBytes = false;
45 UsesELFSectionDirectiveForBSS = true;
46 SupportsDebugInformation = true;
47 UseDataRegionDirectives = true;
49 ExceptionsType = ExceptionHandling::DwarfCFI;
52 const MCExpr *ARM64MCAsmInfoDarwin::getExprForPersonalitySymbol(
53 const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
54 // On Darwin, we can reference dwarf symbols with foo@GOT-., which
55 // is an indirect pc-relative reference. The default implementation
56 // won't reference using the GOT, so we need this target-specific
58 MCContext &Context = Streamer.getContext();
60 MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOT, Context);
61 MCSymbol *PCSym = Context.CreateTempSymbol();
62 Streamer.EmitLabel(PCSym);
63 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
64 return MCBinaryExpr::CreateSub(Res, PC, Context);
67 ARM64MCAsmInfoELF::ARM64MCAsmInfoELF(StringRef TT) {
69 if (T.getArch() == Triple::aarch64_be)
70 IsLittleEndian = false;
72 // We prefer NEON instructions to be printed in the short form.
73 AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
77 // ".comm align is in bytes but .align is pow-2."
78 AlignmentIsInBytes = false;
81 PrivateGlobalPrefix = ".L";
82 Code32Directive = ".code\t32";
84 Data16bitsDirective = "\t.hword\t";
85 Data32bitsDirective = "\t.word\t";
86 Data64bitsDirective = "\t.xword\t";
88 UseDataRegionDirectives = false;
90 WeakRefDirective = "\t.weak\t";
93 SupportsDebugInformation = true;
95 // Exceptions handling
96 ExceptionsType = ExceptionHandling::DwarfCFI;
98 UseIntegratedAssembler = true;