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
68}
69
70void ARMELFMCAsmInfo::anchor() { }
71
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 = "@";
84
86
87 // Conditional Thumb 4-byte instructions can have an implicit IT.
88 MaxInstLength = 6;
89
91 // foo(plt) instead of foo@plt
92 UseAtForSpecifier = false;
94}
95
99 // gas doesn't handle VFP register names in cfi directives,
100 // so don't use register names with external assembler.
101 // See https://sourceware.org/bugzilla/show_bug.cgi?id=16694
102 DwarfRegNumForCFI = true;
103 }
104}
105
106void ARMCOFFMCAsmInfoMicrosoft::anchor() { }
107
111 AlignmentIsInBytes = false;
115 CommentString = "@";
116
117 // Conditional Thumb 4-byte instructions can have an implicit IT.
118 MaxInstLength = 6;
119
121}
122
123void ARMCOFFMCAsmInfoGNU::anchor() { }
124
127 AlignmentIsInBytes = false;
129
130 CommentString = "@";
132
135 DwarfRegNumForCFI = false;
136
137 // Conditional Thumb 4-byte instructions can have an implicit IT.
138 MaxInstLength = 6;
139
141 UseAtForSpecifier = false;
143}
144
146 const MCSpecifierExpr &Expr) {
147 switch (Expr.getSpecifier()) {
148 default:
149 llvm_unreachable("Invalid kind!");
150 case ARM::S_HI16:
151 OS << ":upper16:";
152 break;
153 case ARM::S_LO16:
154 OS << ":lower16:";
155 break;
156 case ARM::S_HI_8_15:
157 OS << ":upper8_15:";
158 break;
159 case ARM::S_HI_0_7:
160 OS << ":upper0_7:";
161 break;
162 case ARM::S_LO_8_15:
163 OS << ":lower8_15:";
164 break;
165 case ARM::S_LO_0_7:
166 OS << ":lower0_7:";
167 break;
168 }
169
170 const MCExpr *Sub = Expr.getSubExpr();
171 if (Sub->getKind() != MCExpr::SymbolRef)
172 OS << '(';
173 MAI.printExpr(OS, *Sub);
174 if (Sub->getKind() != MCExpr::SymbolRef)
175 OS << ')';
176}
177
179 return MCSpecifierExpr::create(Expr, ARM::S_HI16, Ctx);
180}
181
183 return MCSpecifierExpr::create(Expr, ARM::S_LO16, Ctx);
184}
185
187 MCContext &Ctx) {
188 return MCSpecifierExpr::create(Expr, ARM::S_HI_8_15, Ctx);
189}
190
192 return MCSpecifierExpr::create(Expr, ARM::S_HI_0_7, Ctx);
193}
194
196 MCContext &Ctx) {
197 return MCSpecifierExpr::create(Expr, ARM::S_LO_8_15, Ctx);
198}
199
201 return MCSpecifierExpr::create(Expr, ARM::S_LO_0_7, Ctx);
202}
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:387
const char * Data64bitsDirective
Definition MCAsmInfo.h:248
bool UseIntegratedAssembler
Should we use the integrated assembler?
Definition MCAsmInfo.h:414
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition MCAsmInfo.h:365
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:391
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition MCAsmInfo.h:357
bool HasSingleParameterDotFile
True if the target has a single parameter .file directive, this is true for ELF targets.
Definition MCAsmInfo.h:311
bool AlignmentIsInBytes
If this is true (the default) then the asmprinter emits ".align N" directives, where N is the number ...
Definition MCAsmInfo.h:271
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:384
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
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:515
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.
@ Sub
Subtraction of integers.
Compile-time data representation of enum entries.
Definition Enum.h:47