LLVM 24.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/ADT/Enum.h"
15#include "llvm/MC/MCExpr.h"
18
19using namespace llvm;
20
22 {{"GOT_PREL"}, ARM::S_GOT_PREL},
23 {{"none"}, ARM::S_ARM_NONE},
24 {{"prel31"}, ARM::S_PREL31},
25 {{"sbrel"}, ARM::S_SBREL},
26 {{"target1"}, ARM::S_TARGET1},
27 {{"target2"}, ARM::S_TARGET2},
28 {{"TLSLDO"}, ARM::S_TLSLDO},
30 {{"FUNCDESC"}, ARM::S_FUNCDESC},
31 {{"GOT"}, ARM::S_GOT},
32 {{"GOTFUNCDESC"}, ARM::S_GOTFUNCDESC},
33 {{"GOTOFF"}, ARM::S_GOTOFF},
34 {{"GOTOFFFUNCDESC"}, ARM::S_GOTOFFFUNCDESC},
35 {{"GOTTPOFF"}, ARM::S_GOTTPOFF},
36 {{"gottpoff_fdpic"}, ARM::S_GOTTPOFF_FDPIC},
37 {{"PLT"}, ARM::S_PLT},
38 {{"SECREL32"}, ARM::S_COFF_SECREL},
39 {{"tlscall"}, ARM::S_TLSCALL},
40 {{"tlsdesc"}, ARM::S_TLSDESC},
41 {{"TLSGD"}, ARM::S_TLSGD},
42 {{"tlsgd_fdpic"}, ARM::S_TLSGD_FDPIC},
43 {{"TLSLDM"}, ARM::S_TLSLDM},
44 {{"tlsldm_fdpic"}, ARM::S_TLSLDM_FDPIC},
45 {{"TPOFF"}, ARM::S_TPOFF},
46};
48
49void ARMMCAsmInfoDarwin::anchor() { }
50
54 if ((TheTriple.getArch() == Triple::armeb) ||
55 (TheTriple.getArch() == Triple::thumbeb))
56 IsLittleEndian = false;
57
58 Data64bitsDirective = nullptr;
59 CommentString = "@";
61
63
64 // Conditional Thumb 4-byte instructions can have an implicit IT.
65 MaxInstLength = 6;
66
67 // Exceptions handling
68 ExceptionsType = (TheTriple.isOSDarwin() && !TheTriple.isWatchABI())
71
73}
74
75void ARMELFMCAsmInfo::anchor() { }
76
80 if ((TheTriple.getArch() == Triple::armeb) ||
81 (TheTriple.getArch() == Triple::thumbeb))
82 IsLittleEndian = false;
83
84 // ".comm align is in bytes but .align is pow-2."
85 AlignmentIsInBytes = false;
86
87 Data64bitsDirective = nullptr;
88 CommentString = "@";
89
91
92 // Conditional Thumb 4-byte instructions can have an implicit IT.
93 MaxInstLength = 6;
94
95 // Exceptions handling
96 switch (TheTriple.getOS()) {
97 case Triple::NetBSD:
98 ExceptionsType = ExceptionHandling::DwarfCFI;
99 break;
100 default:
101 ExceptionsType = ExceptionHandling::ARM;
102 break;
103 }
104
106 // foo(plt) instead of foo@plt
107 UseAtForSpecifier = false;
109}
110
114 // gas doesn't handle VFP register names in cfi directives,
115 // so don't use register names with external assembler.
116 // See https://sourceware.org/bugzilla/show_bug.cgi?id=16694
117 DwarfRegNumForCFI = true;
118 }
119}
120
121void ARMCOFFMCAsmInfoMicrosoft::anchor() { }
122
138
139void ARMCOFFMCAsmInfoGNU::anchor() { }
140
143 AlignmentIsInBytes = false;
145
146 CommentString = "@";
148
152 DwarfRegNumForCFI = false;
153
154 // Conditional Thumb 4-byte instructions can have an implicit IT.
155 MaxInstLength = 6;
156
158 UseAtForSpecifier = false;
160}
161
163 const MCSpecifierExpr &Expr) {
164 switch (Expr.getSpecifier()) {
165 default:
166 llvm_unreachable("Invalid kind!");
167 case ARM::S_HI16:
168 OS << ":upper16:";
169 break;
170 case ARM::S_LO16:
171 OS << ":lower16:";
172 break;
173 case ARM::S_HI_8_15:
174 OS << ":upper8_15:";
175 break;
176 case ARM::S_HI_0_7:
177 OS << ":upper0_7:";
178 break;
179 case ARM::S_LO_8_15:
180 OS << ":lower8_15:";
181 break;
182 case ARM::S_LO_0_7:
183 OS << ":lower0_7:";
184 break;
185 }
186
187 const MCExpr *Sub = Expr.getSubExpr();
188 if (Sub->getKind() != MCExpr::SymbolRef)
189 OS << '(';
190 MAI.printExpr(OS, *Sub);
191 if (Sub->getKind() != MCExpr::SymbolRef)
192 OS << ')';
193}
194
196 return MCSpecifierExpr::create(Expr, ARM::S_HI16, Ctx);
197}
198
200 return MCSpecifierExpr::create(Expr, ARM::S_LO16, Ctx);
201}
202
204 MCContext &Ctx) {
205 return MCSpecifierExpr::create(Expr, ARM::S_HI_8_15, Ctx);
206}
207
209 return MCSpecifierExpr::create(Expr, ARM::S_HI_0_7, Ctx);
210}
211
213 MCContext &Ctx) {
214 return MCSpecifierExpr::create(Expr, ARM::S_LO_8_15, Ctx);
215}
216
218 return MCSpecifierExpr::create(Expr, ARM::S_LO_0_7, Ctx);
219}
constexpr EnumStringDef< MCAsmInfo::AtSpecifierKind > AtSpecifierDefs[]
constexpr auto atSpecifiers
#define BUILD_ENUM_STRINGS(Tab)
Definition Enum.h:120
static LVOptions Options
Definition LVOptions.cpp:25
ARMCOFFMCAsmInfoGNU(const MCTargetOptions &Options)
ARMCOFFMCAsmInfoMicrosoft(const MCTargetOptions &Options)
void setUseIntegratedAssembler(bool Value) override
Set whether assembly (inline or otherwise) should be parsed.
ARMELFMCAsmInfo(const Triple &TT, const MCTargetOptions &Options)
ARMMCAsmInfoDarwin(const Triple &TheTriple, const MCTargetOptions &Options)
MCAsmInfoDarwin(const MCTargetOptions &Options)
MCAsmInfoELF(const MCTargetOptions &Options)
MCAsmInfoGNUCOFF(const MCTargetOptions &Options)
MCAsmInfoMicrosoft(const MCTargetOptions &Options)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:67
StringRef InternalSymbolPrefix
For internal use by compiler and assembler, not meant to be visible externally.
Definition MCAsmInfo.h:159
bool UseAtForSpecifier
True if target uses @ (expr@specifier) for relocation specifiers.
Definition MCAsmInfo.h:386
const char * Data64bitsDirective
Definition MCAsmInfo.h:245
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition MCAsmInfo.h:357
bool UseIntegratedAssembler
Should we use the integrated assembler?
Definition MCAsmInfo.h:413
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition MCAsmInfo.h:364
void printExpr(raw_ostream &, const MCExpr &) const
unsigned MaxInstLength
This is the maximum possible length of an instruction, which is needed to compute the size of an inli...
Definition MCAsmInfo.h:118
bool UseParensForSpecifier
(ARM-specific) Uses parens for relocation specifier in data directives, e.g.
Definition MCAsmInfo.h:390
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition MCAsmInfo.h:354
bool HasSingleParameterDotFile
True if the target has a single parameter .file directive, this is true for ELF targets.
Definition MCAsmInfo.h:308
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition MCAsmInfo.h:268
void initializeAtSpecifiers(EnumStrings< AtSpecifierKind, 1 >)
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives.
Definition MCAsmInfo.h:207
bool DwarfRegNumForCFI
True if dwarf register numbers are printed instead of symbolic register names in ....
Definition MCAsmInfo.h:383
bool IsLittleEndian
True if target is little endian. Default is true.
Definition MCAsmInfo.h:93
StringRef CommentString
This indicates the comment string used by the assembler.
Definition MCAsmInfo.h:134
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:494
const MCExpr * getSubExpr() const
Definition MCExpr.h:508
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Spec getSpecifier() const
Definition MCExpr.h:507
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
bool isWatchABI() const
Definition Triple.h:696
OSType getOS() const
Get the parsed operating system type of this triple.
Definition Triple.h:521
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:512
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).
Definition Triple.h:721
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)
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.
Definition MCAsmInfo.h:52
This is an optimization pass for GlobalISel generic memory operations.
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:56
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:55
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:58
@ Sub
Subtraction of integers.
Compile-time data representation of enum entries.
Definition Enum.h:47