Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 1 | //===-- 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 Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/Triple.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCContext.h" |
Benjamin Kramer | 1f8930e | 2014-07-25 11:42:14 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCExpr.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCStreamer.h" |
| 19 | #include "llvm/Support/CommandLine.h" |
| 20 | using namespace llvm; |
| 21 | |
| 22 | enum AsmWriterVariantTy { |
| 23 | Default = -1, |
| 24 | Generic = 0, |
| 25 | Apple = 1 |
| 26 | }; |
| 27 | |
| 28 | static 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"), |
Mehdi Amini | 732afdd | 2016-10-08 19:41:06 +0000 | [diff] [blame] | 32 | clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly"))); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 33 | |
| 34 | AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() { |
| 35 | // We prefer NEON instructions to be printed in the short form. |
| 36 | AssemblerDialect = AsmWriterVariant == Default ? 1 : AsmWriterVariant; |
| 37 | |
| 38 | PrivateGlobalPrefix = "L"; |
Matt Arsenault | 4e27343 | 2014-12-04 00:06:57 +0000 | [diff] [blame] | 39 | PrivateLabelPrefix = "L"; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 40 | SeparatorString = "%%"; |
| 41 | CommentString = ";"; |
| 42 | PointerSize = CalleeSaveStackSlotSize = 8; |
| 43 | |
| 44 | AlignmentIsInBytes = false; |
| 45 | UsesELFSectionDirectiveForBSS = true; |
| 46 | SupportsDebugInformation = true; |
| 47 | UseDataRegionDirectives = true; |
| 48 | |
| 49 | ExceptionsType = ExceptionHandling::DwarfCFI; |
| 50 | } |
| 51 | |
| 52 | const MCExpr *AArch64MCAsmInfoDarwin::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 |
| 57 | // version. |
| 58 | MCContext &Context = Streamer.getContext(); |
| 59 | const MCExpr *Res = |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame] | 60 | MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, Context); |
Jim Grosbach | 6f48200 | 2015-05-18 18:43:14 +0000 | [diff] [blame] | 61 | MCSymbol *PCSym = Context.createTempSymbol(); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 62 | Streamer.EmitLabel(PCSym); |
Jim Grosbach | 13760bd | 2015-05-30 01:25:56 +0000 | [diff] [blame] | 63 | const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context); |
| 64 | return MCBinaryExpr::createSub(Res, PC, Context); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 67 | AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) { |
| 68 | if (T.getArch() == Triple::aarch64_be) |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 69 | IsLittleEndian = false; |
| 70 | |
| 71 | // We prefer NEON instructions to be printed in the short form. |
| 72 | AssemblerDialect = AsmWriterVariant == Default ? 0 : AsmWriterVariant; |
| 73 | |
| 74 | PointerSize = 8; |
| 75 | |
| 76 | // ".comm align is in bytes but .align is pow-2." |
| 77 | AlignmentIsInBytes = false; |
| 78 | |
| 79 | CommentString = "//"; |
| 80 | PrivateGlobalPrefix = ".L"; |
Matt Arsenault | 4e27343 | 2014-12-04 00:06:57 +0000 | [diff] [blame] | 81 | PrivateLabelPrefix = ".L"; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 82 | Code32Directive = ".code\t32"; |
| 83 | |
| 84 | Data16bitsDirective = "\t.hword\t"; |
| 85 | Data32bitsDirective = "\t.word\t"; |
| 86 | Data64bitsDirective = "\t.xword\t"; |
| 87 | |
| 88 | UseDataRegionDirectives = false; |
| 89 | |
| 90 | WeakRefDirective = "\t.weak\t"; |
| 91 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 92 | SupportsDebugInformation = true; |
| 93 | |
| 94 | // Exceptions handling |
| 95 | ExceptionsType = ExceptionHandling::DwarfCFI; |
| 96 | |
| 97 | UseIntegratedAssembler = true; |
Chad Rosier | d863ae3 | 2014-06-10 14:32:08 +0000 | [diff] [blame] | 98 | |
| 99 | HasIdentDirective = true; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 100 | } |