LLVM 22.0.0git
ARMMCAsmInfo.cpp
Go to the documentation of this file.
1//===-- ARMMCAsmInfo.cpp - ARM 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 ARMMCAsmInfo properties.
10//
11//===----------------------------------------------------------------------===//
12
13#include "ARMMCAsmInfo.h"
14#include "llvm/MC/MCExpr.h"
17
18using namespace llvm;
19
21 {ARM::S_GOT_PREL, "GOT_PREL"},
22 {ARM::S_ARM_NONE, "none"},
23 {ARM::S_PREL31, "prel31"},
24 {ARM::S_SBREL, "sbrel"},
25 {ARM::S_TARGET1, "target1"},
26 {ARM::S_TARGET2, "target2"},
27 {ARM::S_TLSLDO, "TLSLDO"},
29 {ARM::S_FUNCDESC, "FUNCDESC"},
30 {ARM::S_GOT, "GOT"},
31 {ARM::S_GOTFUNCDESC, "GOTFUNCDESC"},
32 {ARM::S_GOTOFF, "GOTOFF"},
33 {ARM::S_GOTOFFFUNCDESC, "GOTOFFFUNCDESC"},
34 {ARM::S_GOTTPOFF, "GOTTPOFF"},
35 {ARM::S_GOTTPOFF_FDPIC, "gottpoff_fdpic"},
36 {ARM::S_PLT, "PLT"},
37 {ARM::S_COFF_SECREL, "SECREL32"},
38 {ARM::S_TLSCALL, "tlscall"},
39 {ARM::S_TLSDESC, "tlsdesc"},
40 {ARM::S_TLSGD, "TLSGD"},
41 {ARM::S_TLSGD_FDPIC, "tlsgd_fdpic"},
42 {ARM::S_TLSLDM, "TLSLDM"},
43 {ARM::S_TLSLDM_FDPIC, "tlsldm_fdpic"},
44 {ARM::S_TPOFF, "TPOFF"},
45};
46
47void ARMMCAsmInfoDarwin::anchor() { }
48
50 if ((TheTriple.getArch() == Triple::armeb) ||
51 (TheTriple.getArch() == Triple::thumbeb))
52 IsLittleEndian = false;
53
54 Data64bitsDirective = nullptr;
55 CommentString = "@";
58
60
61 // Conditional Thumb 4-byte instructions can have an implicit IT.
62 MaxInstLength = 6;
63
64 // Exceptions handling
65 ExceptionsType = (TheTriple.isOSDarwin() && !TheTriple.isWatchABI())
68
70}
71
72void ARMELFMCAsmInfo::anchor() { }
73
75 if ((TheTriple.getArch() == Triple::armeb) ||
76 (TheTriple.getArch() == Triple::thumbeb))
77 IsLittleEndian = false;
78
79 // ".comm align is in bytes but .align is pow-2."
80 AlignmentIsInBytes = false;
81
82 Data64bitsDirective = nullptr;
83 CommentString = "@";
85
87
88 // Conditional Thumb 4-byte instructions can have an implicit IT.
89 MaxInstLength = 6;
90
91 // Exceptions handling
92 switch (TheTriple.getOS()) {
93 case Triple::NetBSD:
95 break;
96 default:
98 break;
99 }
100
101 // foo(plt) instead of foo@plt
102 UseAtForSpecifier = false;
104
106}
107
111 // gas doesn't handle VFP register names in cfi directives,
112 // so don't use register names with external assembler.
113 // See https://sourceware.org/bugzilla/show_bug.cgi?id=16694
114 DwarfRegNumForCFI = true;
115 }
116}
117
118void ARMCOFFMCAsmInfoMicrosoft::anchor() { }
119
121 AlignmentIsInBytes = false;
125 PrivateGlobalPrefix = "$M";
126 PrivateLabelPrefix = "$M";
127 CommentString = "@";
128
129 // Conditional Thumb 4-byte instructions can have an implicit IT.
130 MaxInstLength = 6;
131
133}
134
135void ARMCOFFMCAsmInfoGNU::anchor() { }
136
138 AlignmentIsInBytes = false;
140
141 CommentString = "@";
143 PrivateGlobalPrefix = ".L";
144 PrivateLabelPrefix = ".L";
145
149 UseAtForSpecifier = false;
151
152 DwarfRegNumForCFI = false;
153
154 // Conditional Thumb 4-byte instructions can have an implicit IT.
155 MaxInstLength = 6;
156
158}
159
161 const MCSpecifierExpr &Expr) {
162 switch (Expr.getSpecifier()) {
163 default:
164 llvm_unreachable("Invalid kind!");
165 case ARM::S_HI16:
166 OS << ":upper16:";
167 break;
168 case ARM::S_LO16:
169 OS << ":lower16:";
170 break;
171 case ARM::S_HI_8_15:
172 OS << ":upper8_15:";
173 break;
174 case ARM::S_HI_0_7:
175 OS << ":upper0_7:";
176 break;
177 case ARM::S_LO_8_15:
178 OS << ":lower8_15:";
179 break;
180 case ARM::S_LO_0_7:
181 OS << ":lower0_7:";
182 break;
183 }
184
185 const MCExpr *Sub = Expr.getSubExpr();
186 if (Sub->getKind() != MCExpr::SymbolRef)
187 OS << '(';
188 MAI.printExpr(OS, *Sub);
189 if (Sub->getKind() != MCExpr::SymbolRef)
190 OS << ')';
191}
192
194 return MCSpecifierExpr::create(Expr, ARM::S_HI16, Ctx);
195}
196
198 return MCSpecifierExpr::create(Expr, ARM::S_LO16, Ctx);
199}
200
202 MCContext &Ctx) {
203 return MCSpecifierExpr::create(Expr, ARM::S_HI_8_15, Ctx);
204}
205
207 return MCSpecifierExpr::create(Expr, ARM::S_HI_0_7, Ctx);
208}
209
211 MCContext &Ctx) {
212 return MCSpecifierExpr::create(Expr, ARM::S_LO_8_15, Ctx);
213}
214
216 return MCSpecifierExpr::create(Expr, ARM::S_LO_0_7, Ctx);
217}
const MCAsmInfo::AtSpecifier atSpecifiers[]
const MCAsmInfo::AtSpecifier atSpecifiers[]
raw_pwrite_stream & OS
ARMELFMCAsmInfo(const Triple &TT)
void setUseIntegratedAssembler(bool Value) override
Set whether assembly (inline or otherwise) should be parsed.
ARMMCAsmInfoDarwin(const Triple &TheTriple)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
bool UseAtForSpecifier
True if target uses @ (expr@specifier) for relocation specifiers.
Definition: MCAsmInfo.h:385
void initializeAtSpecifiers(ArrayRef< AtSpecifier >)
Definition: MCAsmInfo.cpp:127
const char * Data64bitsDirective
Definition: MCAsmInfo.h:250
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition: MCAsmInfo.h:359
bool AllowDollarAtStartOfIdentifier
This is true if the assembler allows the "$" character at the start of of a string to be lexed as an ...
Definition: MCAsmInfo.h:196
StringRef PrivateGlobalPrefix
This prefix is used for globals like constant pool entries that are completely private to the ....
Definition: MCAsmInfo.h:160
bool UseIntegratedAssembler
Should we use the integrated assembler? The integrated assembler should be enabled by default (by the...
Definition: MCAsmInfo.h:412
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition: MCAsmInfo.h:366
StringRef PrivateLabelPrefix
This prefix is used for labels for basic blocks.
Definition: MCAsmInfo.h:164
void printExpr(raw_ostream &, const MCExpr &) const
Definition: MCAsmInfo.cpp:153
unsigned MaxInstLength
This is the maximum possible length of an instruction, which is needed to compute the size of an inli...
Definition: MCAsmInfo.h:119
bool UseParensForSpecifier
(ARM-specific) Uses parens for relocation specifier in data directives, e.g.
Definition: MCAsmInfo.h:389
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition: MCAsmInfo.h:356
bool HasSingleParameterDotFile
True if the target has a single parameter .file directive, this is true for ELF targets.
Definition: MCAsmInfo.h:310
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition: MCAsmInfo.h:273
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives.
Definition: MCAsmInfo.h:212
bool DwarfRegNumForCFI
True if dwarf register numbers are printed instead of symbolic register names in ....
Definition: MCAsmInfo.h:382
bool IsLittleEndian
True if target is little endian. Default is true.
Definition: MCAsmInfo.h:94
StringRef CommentString
This indicates the comment string used by the assembler.
Definition: MCAsmInfo.h:135
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:43
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
Definition: MCExpr.h:495
const MCExpr * getSubExpr() const
Definition: MCExpr.h:509
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.cpp:743
Spec getSpecifier() const
Definition: MCExpr.h:508
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
bool isWatchABI() const
Definition: Triple.h:586
OSType getOS() const
Get the parsed operating system type of this triple.
Definition: Triple.h:417
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition: Triple.h:408
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition: Triple.h:608
LLVM Value Representation.
Definition: Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCSpecifierExpr * createUpper0_7(const MCExpr *Expr, MCContext &Ctx)
@ S_GOTOFFFUNCDESC
Definition: ARMMCAsmInfo.h:116
@ S_GOTTPOFF_FDPIC
Definition: ARMMCAsmInfo.h:118
void printSpecifierExpr(const MCAsmInfo &MAI, raw_ostream &OS, const MCSpecifierExpr &Expr)
const MCSpecifierExpr * createUpper8_15(const MCExpr *Expr, MCContext &Ctx)
const MCSpecifierExpr * createLower16(const MCExpr *Expr, MCContext &Ctx)
const MCSpecifierExpr * createLower0_7(const MCExpr *Expr, MCContext &Ctx)
const MCSpecifierExpr * createLower8_15(const MCExpr *Expr, MCContext &Ctx)
const MCSpecifierExpr * createUpper16(const MCExpr *Expr, MCContext &Ctx)
@ Itanium
Windows CE ARM, PowerPC, SH3, SH4.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ SjLj
setjmp/longjmp based exceptions
@ DwarfCFI
DWARF-like instruction based exceptions.
@ WinEH
Windows Exception Handling.
@ Sub
Subtraction of integers.