LLVM  14.0.0git
AArch64MCAsmInfo.cpp
Go to the documentation of this file.
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"
19 using namespace llvm;
20 
22  Default = -1,
23  Generic = 0,
24  Apple = 1
25 };
26 
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 
34  // We prefer NEON instructions to be printed in the short, Apple-specific
35  // form when targeting Darwin.
37 
38  PrivateGlobalPrefix = "L";
39  PrivateLabelPrefix = "L";
40  SeparatorString = "%%";
41  CommentString = ";";
43  CodePointerSize = IsILP32 ? 4 : 8;
44 
45  AlignmentIsInBytes = false;
49 
51 }
52 
54  const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const {
55  // On Darwin, we can reference dwarf symbols with foo@GOT-., which
56  // is an indirect pc-relative reference. The default implementation
57  // won't reference using the GOT, so we need this target-specific
58  // version.
59  MCContext &Context = Streamer.getContext();
60  const MCExpr *Res =
62  MCSymbol *PCSym = Context.createTempSymbol();
63  Streamer.emitLabel(PCSym);
64  const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
65  return MCBinaryExpr::createSub(Res, PC, Context);
66 }
67 
69  if (T.getArch() == Triple::aarch64_be)
70  IsLittleEndian = false;
71 
72  // We prefer NEON instructions to be printed in the generic form when
73  // targeting ELF.
75 
76  CodePointerSize = T.getEnvironment() == Triple::GNUILP32 ? 4 : 8;
77 
78  // ".comm align is in bytes but .align is pow-2."
79  AlignmentIsInBytes = false;
80 
81  CommentString = "//";
82  PrivateGlobalPrefix = ".L";
83  PrivateLabelPrefix = ".L";
84  Code32Directive = ".code\t32";
85 
86  Data16bitsDirective = "\t.hword\t";
87  Data32bitsDirective = "\t.word\t";
88  Data64bitsDirective = "\t.xword\t";
89 
91 
92  WeakRefDirective = "\t.weak\t";
93 
95 
96  // Exceptions handling
98 
99  HasIdentDirective = true;
100 }
101 
103  PrivateGlobalPrefix = ".L";
104  PrivateLabelPrefix = ".L";
105 
106  Data16bitsDirective = "\t.hword\t";
107  Data32bitsDirective = "\t.word\t";
108  Data64bitsDirective = "\t.xword\t";
109 
110  AlignmentIsInBytes = false;
112  CodePointerSize = 8;
113 
114  CommentString = "//";
117 }
118 
120  PrivateGlobalPrefix = ".L";
121  PrivateLabelPrefix = ".L";
122 
123  Data16bitsDirective = "\t.hword\t";
124  Data32bitsDirective = "\t.word\t";
125  Data64bitsDirective = "\t.xword\t";
126 
127  AlignmentIsInBytes = false;
129  CodePointerSize = 8;
130 
131  CommentString = "//";
134 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::Triple::GNUILP32
@ GNUILP32
Definition: Triple.h:213
llvm::MCSymbolRefExpr::VK_GOT
@ VK_GOT
Definition: MCExpr.h:198
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::AArch64MCAsmInfoGNUCOFF::AArch64MCAsmInfoGNUCOFF
AArch64MCAsmInfoGNUCOFF()
Definition: AArch64MCAsmInfo.cpp:119
AsmWriterVariantTy
AsmWriterVariantTy
Definition: AArch64MCAsmInfo.cpp:21
llvm::MCAsmInfo::SupportsDebugInformation
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition: MCAsmInfo.h:445
llvm::MCAsmInfo::AlignmentIsInBytes
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition: MCAsmInfo.h:329
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::MCAsmInfo::HasIdentDirective
bool HasIdentDirective
True if the target has a .ident directive, this is true for ELF targets.
Definition: MCAsmInfo.h:399
llvm::MCAsmInfo::UsesELFSectionDirectiveForBSS
bool UsesELFSectionDirectiveForBSS
This is true if this target uses ELF '.section' directive before the '.bss' one.
Definition: MCAsmInfo.h:319
llvm::WinEH::EncodingType::Itanium
@ Itanium
Windows CE ARM, PowerPC, SH3, SH4.
llvm::MCAsmInfo::Data64bitsDirective
const char * Data64bitsDirective
Definition: MCAsmInfo.h:288
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::MCAsmInfo::Code32Directive
const char * Code32Directive
Definition: MCAsmInfo.h:189
llvm::MCAsmInfo::PrivateLabelPrefix
StringRef PrivateLabelPrefix
This prefix is used for labels for basic blocks.
Definition: MCAsmInfo.h:172
llvm::MCAsmInfo::UseDataRegionDirectives
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives.
Definition: MCAsmInfo.h:234
llvm::AArch64MCAsmInfoELF::AArch64MCAsmInfoELF
AArch64MCAsmInfoELF(const Triple &T)
Definition: AArch64MCAsmInfo.cpp:68
llvm::MCAsmInfo::Data32bitsDirective
const char * Data32bitsDirective
Definition: MCAsmInfo.h:287
AsmWriterVariant
static cl::opt< AsmWriterVariantTy > AsmWriterVariant("aarch64-neon-syntax", cl::init(Default), cl::desc("Choose style of NEON code to emit from AArch64 backend:"), cl::values(clEnumValN(Generic, "generic", "Emit generic NEON assembly"), clEnumValN(Apple, "apple", "Emit Apple-style NEON assembly")))
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
CommandLine.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::MCAsmInfo::PrivateGlobalPrefix
StringRef PrivateGlobalPrefix
This prefix is used for globals like constant pool entries that are completely private to the ....
Definition: MCAsmInfo.h:168
Apple
@ Apple
Definition: AArch64MCAsmInfo.cpp:24
MCContext.h
llvm::MCStreamer::emitLabel
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:415
llvm::AArch64MCAsmInfoDarwin::getExprForPersonalitySymbol
const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const override
Definition: AArch64MCAsmInfo.cpp:53
AArch64MCAsmInfo.h
llvm::MCAsmInfo::SeparatorString
const char * SeparatorString
This string, if specified, is used to separate instructions from each other when on the same line.
Definition: MCAsmInfo.h:131
llvm::cl::opt
Definition: CommandLine.h:1434
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:699
llvm::MCAsmInfo::WeakRefDirective
const char * WeakRefDirective
This directive, if non-null, is used to declare a global as being a weak undefined symbol.
Definition: MCAsmInfo.h:414
llvm::MCAsmInfo::CommentString
StringRef CommentString
This indicates the comment string used by the assembler.
Definition: MCAsmInfo.h:135
Generic
@ Generic
Definition: AArch64MCAsmInfo.cpp:23
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::MCAsmInfo::CodePointerSize
unsigned CodePointerSize
Code pointer size in bytes. Default is 4.
Definition: MCAsmInfo.h:72
llvm::MCAsmInfo::AssemblerDialect
unsigned AssemblerDialect
Which dialect of an assembler variant to use. Defaults to 0.
Definition: MCAsmInfo.h:193
llvm::MCBinaryExpr::createSub
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:609
llvm::MCAsmInfo::WinEHEncodingType
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition: MCAsmInfo.h:455
llvm::MCAsmInfo::Data16bitsDirective
const char * Data16bitsDirective
Definition: MCAsmInfo.h:286
llvm::AArch64MCAsmInfoMicrosoftCOFF::AArch64MCAsmInfoMicrosoftCOFF
AArch64MCAsmInfoMicrosoftCOFF()
Definition: AArch64MCAsmInfo.cpp:102
Triple.h
llvm::Triple::aarch64_be
@ aarch64_be
Definition: Triple.h:53
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:674
llvm::MCAsmInfo::CalleeSaveStackSlotSize
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
Definition: MCAsmInfo.h:76
llvm::ExceptionHandling::WinEH
@ WinEH
Windows Exception Handling.
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:385
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition: MCStreamer.h:280
MCStreamer.h
llvm::MCAsmInfo::ExceptionsType
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition: MCAsmInfo.h:448
llvm::cl::desc
Definition: CommandLine.h:414
llvm::AArch64MCAsmInfoDarwin::AArch64MCAsmInfoDarwin
AArch64MCAsmInfoDarwin(bool IsILP32)
Definition: AArch64MCAsmInfo.cpp:33
MCExpr.h
llvm::ExceptionHandling::DwarfCFI
@ DwarfCFI
DWARF-like instruction based exceptions.
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::MCAsmInfo::IsLittleEndian
bool IsLittleEndian
True if target is little endian. Default is true.
Definition: MCAsmInfo.h:79