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
51void ARMMCAsmInfoDarwin::anchor() { }
52
56 if ((TheTriple.getArch() == Triple::armeb) ||
57 (TheTriple.getArch() == Triple::thumbeb))
58 IsLittleEndian = false;
59
60 Data64bitsDirective = nullptr;
61 CommentString = "@";
63
65
66 // Conditional Thumb 4-byte instructions can have an implicit IT.
67 MaxInstLength = 6;
68
70}
71
72void ARMELFMCAsmInfo::anchor() { }
73
77 if ((TheTriple.getArch() == Triple::armeb) ||
78 (TheTriple.getArch() == Triple::thumbeb))
79 IsLittleEndian = false;
80
81 // ".comm align is in bytes but .align is pow-2."
82 AlignmentIsInBytes = false;
83
84 Data64bitsDirective = nullptr;
85 CommentString = "@";
86
88
89 // Conditional Thumb 4-byte instructions can have an implicit IT.
90 MaxInstLength = 6;
91
93 // foo(plt) instead of foo@plt
94 UseAtForSpecifier = false;
96}
97
101 // gas doesn't handle VFP register names in cfi directives,
102 // so don't use register names with external assembler.
103 // See https://sourceware.org/bugzilla/show_bug.cgi?id=16694
104 DwarfRegNumForCFI = true;
105 }
106}
107
109 // Thumb encoding uses compressed instruction byte-order
110 return STI.hasFeature(ARM::ModeThumb);
111}
112
113void ARMCOFFMCAsmInfoMicrosoft::anchor() { }
114
118 AlignmentIsInBytes = false;
122 CommentString = "@";
123
124 // Conditional Thumb 4-byte instructions can have an implicit IT.
125 MaxInstLength = 6;
126
128}
129
130void ARMCOFFMCAsmInfoGNU::anchor() { }
131
134 AlignmentIsInBytes = false;
136
137 CommentString = "@";
139
142 DwarfRegNumForCFI = false;
143
144 // Conditional Thumb 4-byte instructions can have an implicit IT.
145 MaxInstLength = 6;
146
148 UseAtForSpecifier = false;
150}
151
153 const MCSpecifierExpr &Expr) {
154 switch (Expr.getSpecifier()) {
155 default:
156 llvm_unreachable("Invalid kind!");
157 case ARM::S_HI16:
158 OS << ":upper16:";
159 break;
160 case ARM::S_LO16:
161 OS << ":lower16:";
162 break;
163 case ARM::S_HI_8_15:
164 OS << ":upper8_15:";
165 break;
166 case ARM::S_HI_0_7:
167 OS << ":upper0_7:";
168 break;
169 case ARM::S_LO_8_15:
170 OS << ":lower8_15:";
171 break;
172 case ARM::S_LO_0_7:
173 OS << ":lower0_7:";
174 break;
175 }
176
177 const MCExpr *Sub = Expr.getSubExpr();
178 if (Sub->getKind() != MCExpr::SymbolRef)
179 OS << '(';
180 MAI.printExpr(OS, *Sub);
181 if (Sub->getKind() != MCExpr::SymbolRef)
182 OS << ')';
183}
184
186 return MCSpecifierExpr::create(Expr, ARM::S_HI16, Ctx);
187}
188
190 return MCSpecifierExpr::create(Expr, ARM::S_LO16, Ctx);
191}
192
194 MCContext &Ctx) {
195 return MCSpecifierExpr::create(Expr, ARM::S_HI_8_15, Ctx);
196}
197
199 return MCSpecifierExpr::create(Expr, ARM::S_HI_0_7, Ctx);
200}
201
203 MCContext &Ctx) {
204 return MCSpecifierExpr::create(Expr, ARM::S_LO_8_15, Ctx);
205}
206
208 return MCSpecifierExpr::create(Expr, ARM::S_LO_0_7, Ctx);
209}
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)
bool usesCompInstByteOrder(const MCSubtargetInfo &STI) const override
True if the instruction is stored in multiple halfwords, with the high-order half appearing first in ...
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
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
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