LLVM API Documentation

AArch64MCAsmInfo.cpp
Go to the documentation of this file.
00001 //===-- AArch64MCAsmInfo.cpp - AArch64 asm properties ---------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declarations of the AArch64MCAsmInfo properties.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "AArch64MCAsmInfo.h"
00015 #include "llvm/ADT/Triple.h"
00016 #include "llvm/MC/MCContext.h"
00017 #include "llvm/MC/MCExpr.h"
00018 #include "llvm/MC/MCStreamer.h"
00019 #include "llvm/Support/CommandLine.h"
00020 using namespace llvm;
00021 
00022 enum AsmWriterVariantTy {
00023   Default = -1,
00024   Generic = 0,
00025   Apple = 1
00026 };
00027 
00028 static cl::opt<AsmWriterVariantTy> AsmWriterVariant(
00029     "aarch64-neon-syntax", cl::init(Default),
00030     cl::desc("Choose style of NEON code to emit from AArch64 backend:"),
00031     cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"),
00032                clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly"),
00033                clEnumValEnd));
00034 
00035 AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() {
00036   // We prefer NEON instructions to be printed in the short form.
00037   AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant;
00038 
00039   PrivateGlobalPrefix = "L";
00040   SeparatorString = "%%";
00041   CommentString = ";";
00042   PointerSize = CalleeSaveStackSlotSize = 8;
00043 
00044   AlignmentIsInBytes = false;
00045   UsesELFSectionDirectiveForBSS = true;
00046   SupportsDebugInformation = true;
00047   UseDataRegionDirectives = true;
00048 
00049   ExceptionsType = ExceptionHandling::DwarfCFI;
00050 }
00051 
00052 const MCExpr *AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol(
00053     const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
00054   // On Darwin, we can reference dwarf symbols with foo@GOT-., which
00055   // is an indirect pc-relative reference. The default implementation
00056   // won't reference using the GOT, so we need this target-specific
00057   // version.
00058   MCContext &Context = Streamer.getContext();
00059   const MCExpr *Res =
00060       MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOT, Context);
00061   MCSymbol *PCSym = Context.CreateTempSymbol();
00062   Streamer.EmitLabel(PCSym);
00063   const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
00064   return MCBinaryExpr::CreateSub(Res, PC, Context);
00065 }
00066 
00067 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(StringRef TT) {
00068   Triple T(TT);
00069   if (T.getArch() == Triple::aarch64_be)
00070     IsLittleEndian = false;
00071 
00072   // We prefer NEON instructions to be printed in the short form.
00073   AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant;
00074 
00075   PointerSize = 8;
00076 
00077   // ".comm align is in bytes but .align is pow-2."
00078   AlignmentIsInBytes = false;
00079 
00080   CommentString = "//";
00081   PrivateGlobalPrefix = ".L";
00082   Code32Directive = ".code\t32";
00083 
00084   Data16bitsDirective = "\t.hword\t";
00085   Data32bitsDirective = "\t.word\t";
00086   Data64bitsDirective = "\t.xword\t";
00087 
00088   UseDataRegionDirectives = false;
00089 
00090   WeakRefDirective = "\t.weak\t";
00091 
00092   SupportsDebugInformation = true;
00093 
00094   // Exceptions handling
00095   ExceptionsType = ExceptionHandling::DwarfCFI;
00096 
00097   UseIntegratedAssembler = true;
00098 
00099   HasIdentDirective = true;
00100 }