]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
Move all sources from the llvm project into contrib/llvm-project.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / AArch64 / MCTargetDesc / AArch64MCAsmInfo.cpp
1 //===-- AArch64MCAsmInfo.cpp - AArch64 asm properties ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declarations of the AArch64MCAsmInfo properties.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "AArch64MCAsmInfo.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/MC/MCContext.h"
16 #include "llvm/MC/MCExpr.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     "aarch64-neon-syntax", cl::init(Default),
29     cl::desc("Choose style of NEON code to emit from AArch64 backend:"),
30     cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"),
31                clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly")));
32
33 AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin() {
34   // We prefer NEON instructions to be printed in the short, Apple-specific
35   // form when targeting Darwin.
36   AssemblerDialect = AsmWriterVariant == Default ? Apple : AsmWriterVariant;
37
38   PrivateGlobalPrefix = "L";
39   PrivateLabelPrefix = "L";
40   SeparatorString = "%%";
41   CommentString = ";";
42   CodePointerSize = 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 =
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);
65 }
66
67 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
68   if (T.getArch() == Triple::aarch64_be)
69     IsLittleEndian = false;
70
71   // We prefer NEON instructions to be printed in the generic form when
72   // targeting ELF.
73   AssemblerDialect = AsmWriterVariant == Default ? Generic : AsmWriterVariant;
74
75   CodePointerSize = 8;
76
77   // ".comm align is in bytes but .align is pow-2."
78   AlignmentIsInBytes = false;
79
80   CommentString = "//";
81   PrivateGlobalPrefix = ".L";
82   PrivateLabelPrefix = ".L";
83   Code32Directive = ".code\t32";
84
85   Data16bitsDirective = "\t.hword\t";
86   Data32bitsDirective = "\t.word\t";
87   Data64bitsDirective = "\t.xword\t";
88
89   UseDataRegionDirectives = false;
90
91   WeakRefDirective = "\t.weak\t";
92
93   SupportsDebugInformation = true;
94
95   // Exceptions handling
96   ExceptionsType = ExceptionHandling::DwarfCFI;
97
98   UseIntegratedAssembler = true;
99
100   HasIdentDirective = true;
101 }
102
103 AArch64MCAsmInfoMicrosoftCOFF::AArch64MCAsmInfoMicrosoftCOFF() {
104   PrivateGlobalPrefix = ".L";
105   PrivateLabelPrefix = ".L";
106
107   Data16bitsDirective = "\t.hword\t";
108   Data32bitsDirective = "\t.word\t";
109   Data64bitsDirective = "\t.xword\t";
110
111   AlignmentIsInBytes = false;
112   SupportsDebugInformation = true;
113   CodePointerSize = 8;
114
115   CommentString = ";";
116   ExceptionsType = ExceptionHandling::WinEH;
117   WinEHEncodingType = WinEH::EncodingType::Itanium;
118 }
119
120 AArch64MCAsmInfoGNUCOFF::AArch64MCAsmInfoGNUCOFF() {
121   PrivateGlobalPrefix = ".L";
122   PrivateLabelPrefix = ".L";
123
124   Data16bitsDirective = "\t.hword\t";
125   Data32bitsDirective = "\t.word\t";
126   Data64bitsDirective = "\t.xword\t";
127
128   AlignmentIsInBytes = false;
129   SupportsDebugInformation = true;
130   CodePointerSize = 8;
131
132   CommentString = "//";
133   ExceptionsType = ExceptionHandling::WinEH;
134   WinEHEncodingType = WinEH::EncodingType::Itanium;
135 }