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 "ARMMCTargetDesc.h"
15#include "llvm/ADT/Enum.h"
16#include "llvm/MC/MCExpr.h"
20
21using namespace llvm;
22
24 {{"GOT_PREL"}, ARM::S_GOT_PREL},
25 {{"none"}, ARM::S_ARM_NONE},
26 {{"prel31"}, ARM::S_PREL31},
27 {{"sbrel"}, ARM::S_SBREL},
28 {{"target1"}, ARM::S_TARGET1},
29 {{"target2"}, ARM::S_TARGET2},
30 {{"TLSLDO"}, ARM::S_TLSLDO},
32 {{"FUNCDESC"}, ARM::S_FUNCDESC},
33 {{"GOT"}, ARM::S_GOT},
34 {{"GOTFUNCDESC"}, ARM::S_GOTFUNCDESC},
35 {{"GOTOFF"}, ARM::S_GOTOFF},
36 {{"GOTOFFFUNCDESC"}, ARM::S_GOTOFFFUNCDESC},
37 {{"GOTTPOFF"}, ARM::S_GOTTPOFF},
38 {{"gottpoff_fdpic"}, ARM::S_GOTTPOFF_FDPIC},
39 {{"PLT"}, ARM::S_PLT},
40 {{"SECREL32"}, ARM::S_COFF_SECREL},
41 {{"tlscall"}, ARM::S_TLSCALL},
42 {{"tlsdesc"}, ARM::S_TLSDESC},
43 {{"TLSGD"}, ARM::S_TLSGD},
44 {{"tlsgd_fdpic"}, ARM::S_TLSGD_FDPIC},
45 {{"TLSLDM"}, ARM::S_TLSLDM},
46 {{"tlsldm_fdpic"}, ARM::S_TLSLDM_FDPIC},
47 {{"TPOFF"}, ARM::S_TPOFF},
48};
50
51static void printSpecifierExpr(const MCAsmInfo &MAI, raw_ostream &OS,
52 const MCSpecifierExpr &Expr) {
53 switch (Expr.getSpecifier()) {
54 default:
55 llvm_unreachable("Invalid kind!");
56 case ARM::S_HI16:
57 OS << ":upper16:";
58 break;
59 case ARM::S_LO16:
60 OS << ":lower16:";
61 break;
62 case ARM::S_HI_8_15:
63 OS << ":upper8_15:";
64 break;
65 case ARM::S_HI_0_7:
66 OS << ":upper0_7:";
67 break;
68 case ARM::S_LO_8_15:
69 OS << ":lower8_15:";
70 break;
71 case ARM::S_LO_0_7:
72 OS << ":lower0_7:";
73 break;
74 }
75
76 const MCExpr *Sub = Expr.getSubExpr();
77 if (Sub->getKind() != MCExpr::SymbolRef)
78 OS << '(';
79 MAI.printExpr(OS, *Sub);
80 if (Sub->getKind() != MCExpr::SymbolRef)
81 OS << ')';
82}
83
87 if ((TheTriple.getArch() == Triple::armeb) ||
88 (TheTriple.getArch() == Triple::thumbeb))
89 IsLittleEndian = false;
90
91 Data64bitsDirective = nullptr;
92 CommentString = "@";
94
96
97 // Conditional Thumb 4-byte instructions can have an implicit IT.
98 MaxInstLength = 6;
99
101
104 const MCAssembler *Asm) { return false; };
105}
106
109 : MCAsmInfoELF(TheTriple, Options) {
110 if ((TheTriple.getArch() == Triple::armeb) ||
111 (TheTriple.getArch() == Triple::thumbeb))
112 IsLittleEndian = false;
113 // Thumb encoding uses compressed instruction byte-order
114 CompInstByteOrderFeature = ARM::ModeThumb;
115
116 // ".comm align is in bytes but .align is pow-2."
117 AlignmentIsInBytes = false;
118
119 Data64bitsDirective = nullptr;
120 CommentString = "@";
121
123
124 // Conditional Thumb 4-byte instructions can have an implicit IT.
125 MaxInstLength = 6;
126
128 // foo(plt) instead of foo@plt
129 UseAtForSpecifier = false;
131
132 if (!binutilsIsAtLeast(2, 25)) {
133 // gas doesn't handle VFP register names in cfi directives. As we don't know
134 // at this point whether the integrated assembler is used, don't use
135 // register names if we are not sure that the assembler supports then.
136 // See https://sourceware.org/bugzilla/show_bug.cgi?id=16694
137 DwarfRegNumForCFI = true;
138 }
139
140 // .bss is supported without .section.
141 SectionDirectives.insert(".bss");
142
145 const MCAssembler *Asm) { return false; };
146}
147
151 AlignmentIsInBytes = false;
155 CommentString = "@";
156
157 // Conditional Thumb 4-byte instructions can have an implicit IT.
158 MaxInstLength = 6;
159
161
164 const MCAssembler *Asm) { return false; };
165}
166
169 AlignmentIsInBytes = false;
171
172 CommentString = "@";
174
177 DwarfRegNumForCFI = false;
178
179 // Conditional Thumb 4-byte instructions can have an implicit IT.
180 MaxInstLength = 6;
181
183 UseAtForSpecifier = false;
185
188 const MCAssembler *Asm) { return false; };
189}
190
192 return MCSpecifierExpr::create(Expr, ARM::S_HI16, Ctx);
193}
194
196 return MCSpecifierExpr::create(Expr, ARM::S_LO16, Ctx);
197}
198
200 MCContext &Ctx) {
201 return MCSpecifierExpr::create(Expr, ARM::S_HI_8_15, Ctx);
202}
203
205 return MCSpecifierExpr::create(Expr, ARM::S_HI_0_7, Ctx);
206}
207
209 MCContext &Ctx) {
210 return MCSpecifierExpr::create(Expr, ARM::S_LO_8_15, Ctx);
211}
212
214 return MCSpecifierExpr::create(Expr, ARM::S_LO_0_7, Ctx);
215}
constexpr EnumStringDef< MCAsmInfo::AtSpecifierKind > AtSpecifierDefs[]
constexpr auto atSpecifiers
static void printSpecifierExpr(const MCAsmInfo &MAI, raw_ostream &OS, const MCSpecifierExpr &Expr)
#define BUILD_ENUM_STRINGS(Tab)
Definition Enum.h:120
static LVOptions Options
Definition LVOptions.cpp:25
ARMCOFFMCAsmInfoGNU(const MCTargetOptions &Options)
ARMCOFFMCAsmInfoMicrosoft(const MCTargetOptions &Options)
ARMELFMCAsmInfo(const Triple &TT, const MCTargetOptions &Options)
ARMMCAsmInfoDarwin(const Triple &TheTriple, const MCTargetOptions &Options)
MCAsmInfoDarwin(const MCTargetOptions &Options)
MCAsmInfoELF(const Triple &TT, 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:69
StringRef InternalSymbolPrefix
For internal use by compiler and assembler, not meant to be visible externally.
Definition MCAsmInfo.h:169
bool(* SpecifierExprEvaluateFn)(const MCSpecifierExpr &E, MCValue &Res, const MCAssembler *Asm)
Definition MCAsmInfo.h:231
bool UseAtForSpecifier
True if target uses @ (expr@specifier) for relocation specifiers.
Definition MCAsmInfo.h:411
std::optional< unsigned > CompInstByteOrderFeature
Feature that indicates mixed-endian byte order.
Definition MCAsmInfo.h:99
const char * Data64bitsDirective
Definition MCAsmInfo.h:264
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition MCAsmInfo.h:380
void printExpr(raw_ostream &, const MCExpr &) const
SmallDenseSet< StringRef, 8 > SectionDirectives
Sections whose name also is supported as a directive without an explicit ".section" directive.
Definition MCAsmInfo.h:475
unsigned MaxInstLength
This is the maximum possible length of an instruction, which is needed to compute the size of an inli...
Definition MCAsmInfo.h:128
bool UseParensForSpecifier
(ARM-specific) Uses parens for relocation specifier in data directives, e.g.
Definition MCAsmInfo.h:415
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition MCAsmInfo.h:372
void(* SpecifierExprPrintFn)(const MCAsmInfo &, raw_ostream &, const MCSpecifierExpr &)
Definition MCAsmInfo.h:228
bool HasSingleParameterDotFile
True if the target has a single parameter .file directive, this is true for ELF targets.
Definition MCAsmInfo.h:326
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition MCAsmInfo.h:286
bool binutilsIsAtLeast(int Major, int Minor) const
Definition MCAsmInfo.h:761
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:217
bool DwarfRegNumForCFI
True if dwarf register numbers are printed instead of symbolic register names in ....
Definition MCAsmInfo.h:408
bool IsLittleEndian
True if target is little endian. Default is true.
Definition MCAsmInfo.h:95
StringRef CommentString
This indicates the comment string used by the assembler.
Definition MCAsmInfo.h:144
Context object for machine code objects.
Definition MCContext.h:84
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:31
@ SymbolRef
References to labels and assigned expressions.
Definition MCExpr.h:40
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
Definition MCExpr.h:491
const MCExpr * getSubExpr() const
Definition MCExpr.h:505
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Spec getSpecifier() const
Definition MCExpr.h:504
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:518
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)
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.
@ Sub
Subtraction of integers.
Compile-time data representation of enum entries.
Definition Enum.h:47