LLVM 22.0.0git
MCExpr.h
Go to the documentation of this file.
1//===- MCExpr.h - Assembly Level Expressions --------------------*- C++ -*-===//
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#ifndef LLVM_MC_MCEXPR_H
10#define LLVM_MC_MCEXPR_H
11
12#include "llvm/ADT/DenseMap.h"
14#include "llvm/Support/SMLoc.h"
15#include <cstdint>
16
17namespace llvm {
18
19class MCAsmInfo;
20class MCAssembler;
21class MCContext;
22class MCFixup;
23class MCFragment;
24class MCSection;
25class MCStreamer;
26class MCSymbol;
27class MCValue;
28class raw_ostream;
29class StringRef;
30class MCSymbolRefExpr;
31
32/// Base class for the full range of assembler expressions which are
33/// needed for parsing.
34class MCExpr {
35public:
36 // Allow MC classes to access the private `print` function.
37 friend class MCAsmInfo;
38 friend class MCFragment;
39 friend class MCOperand;
41 Binary, ///< Binary expressions.
42 Constant, ///< Constant expressions.
43 SymbolRef, ///< References to labels and assigned expressions.
44 Unary, ///< Unary expressions.
45 Specifier, ///< Expression with a relocation specifier.
46 Target ///< Target specific expression.
47 };
48
49private:
50 static const unsigned NumSubclassDataBits = 24;
51 static_assert(
52 NumSubclassDataBits == CHAR_BIT * (sizeof(unsigned) - sizeof(ExprKind)),
53 "ExprKind and SubclassData together should take up one word");
54
55 ExprKind Kind;
56 /// Field reserved for use by MCExpr subclasses.
57 unsigned SubclassData : NumSubclassDataBits;
58 SMLoc Loc;
59
60 void print(raw_ostream &OS, const MCAsmInfo *MAI,
61 int SurroundingPrec = 0) const;
62 bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
63 bool InSet) const;
64
65protected:
66 using Spec = uint16_t;
67 explicit MCExpr(ExprKind Kind, SMLoc Loc, unsigned SubclassData = 0)
68 : Kind(Kind), SubclassData(SubclassData), Loc(Loc) {
69 assert(SubclassData < (1 << NumSubclassDataBits) &&
70 "Subclass data too large");
71 }
72
74 bool InSet) const;
75
76 unsigned getSubclassData() const { return SubclassData; }
77
78public:
79 MCExpr(const MCExpr &) = delete;
80 MCExpr &operator=(const MCExpr &) = delete;
81
82 /// \name Accessors
83 /// @{
84
85 ExprKind getKind() const { return Kind; }
86 SMLoc getLoc() const { return Loc; }
87
88 /// @}
89 /// \name Utility Methods
90 /// @{
91
92 LLVM_ABI void dump() const;
93
94 /// @}
95 /// \name Expression Evaluation
96 /// @{
97
98 /// Try to evaluate the expression to an absolute value.
99 ///
100 /// \param Res - The absolute value, if evaluation succeeds.
101 /// \return - True on success.
102 LLVM_ABI bool evaluateAsAbsolute(int64_t &Res) const;
103 LLVM_ABI bool evaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
104 LLVM_ABI bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const;
105
106 /// Aggressive variant of evaluateAsRelocatable when relocations are
107 /// unavailable (e.g. .fill). Expects callers to handle errors when true is
108 /// returned.
109 LLVM_ABI bool evaluateKnownAbsolute(int64_t &Res,
110 const MCAssembler &Asm) const;
111
112 /// Try to evaluate the expression to a relocatable value, i.e. an
113 /// expression of the fixed form (a - b + constant).
114 ///
115 /// \param Res - The relocatable value, if evaluation succeeds.
116 /// \param Asm - The assembler object to use for evaluating values.
117 /// \return - True on success.
119 const MCAssembler *Asm) const;
120
121 /// Try to evaluate the expression to the form (a - b + constant) where
122 /// neither a nor b are variables.
123 ///
124 /// This is a more aggressive variant of evaluateAsRelocatable. The intended
125 /// use is for when relocations are not available, like the .size directive.
126 LLVM_ABI bool evaluateAsValue(MCValue &Res, const MCAssembler &Asm) const;
127
128 /// Find the "associated section" for this expression, which is
129 /// currently defined as the absolute section for constants, or
130 /// otherwise the section associated with the first defined symbol in the
131 /// expression.
133
134 /// @}
135
136 LLVM_ABI static bool evaluateSymbolicAdd(const MCAssembler *, bool,
137 const MCValue &, const MCValue &,
138 MCValue &);
139};
140
141//// Represent a constant integer expression.
142class MCConstantExpr : public MCExpr {
143 int64_t Value;
144
145 // Subclass data stores SizeInBytes in bits 0..7 and PrintInHex in bit 8.
146 static const unsigned SizeInBytesBits = 8;
147 static const unsigned SizeInBytesMask = (1 << SizeInBytesBits) - 1;
148 static const unsigned PrintInHexBit = 1 << SizeInBytesBits;
149
150 static unsigned encodeSubclassData(bool PrintInHex, unsigned SizeInBytes) {
151 assert(SizeInBytes <= sizeof(int64_t) && "Excessive size");
152 return SizeInBytes | (PrintInHex ? PrintInHexBit : 0);
153 }
154
155 MCConstantExpr(int64_t Value, bool PrintInHex, unsigned SizeInBytes)
157 encodeSubclassData(PrintInHex, SizeInBytes)), Value(Value) {}
158
159public:
160 /// \name Construction
161 /// @{
162
163 LLVM_ABI static const MCConstantExpr *create(int64_t Value, MCContext &Ctx,
164 bool PrintInHex = false,
165 unsigned SizeInBytes = 0);
166
167 /// @}
168 /// \name Accessors
169 /// @{
170
171 int64_t getValue() const { return Value; }
172 unsigned getSizeInBytes() const {
173 return getSubclassData() & SizeInBytesMask;
174 }
175
176 bool useHexFormat() const { return (getSubclassData() & PrintInHexBit) != 0; }
177
178 /// @}
179
180 static bool classof(const MCExpr *E) {
181 return E->getKind() == MCExpr::Constant;
182 }
183};
184
185/// Represent a reference to a symbol from inside an expression.
186///
187/// A symbol reference in an expression may be a use of a label, a use of an
188/// assembler variable (defined constant), or constitute an implicit definition
189/// of the symbol as external.
190class MCSymbolRefExpr : public MCExpr {
191public:
192 // VariantKind isn't ideal for encoding relocation operators because:
193 // (a) other expressions, like MCConstantExpr (e.g., 4@l) and MCBinaryExpr
194 // (e.g., (a+1)@l), also need it; (b) semantics become unclear (e.g., folding
195 // expressions with @). MCSpecifierExpr, as used by AArch64 and RISC-V, offers
196 // a cleaner approach.
198 VK_COFF_IMGREL32 = 3, // symbol@imgrel (image-relative)
199
201 };
202
203private:
204 /// The symbol being referenced.
205 const MCSymbol *Symbol;
206
207 explicit MCSymbolRefExpr(const MCSymbol *Symbol, Spec specifier,
208 const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
209
210public:
211 /// \name Construction
212 /// @{
213
214 static const MCSymbolRefExpr *create(const MCSymbol *Symbol, MCContext &Ctx,
215 SMLoc Loc = SMLoc()) {
216 return MCSymbolRefExpr::create(Symbol, 0, Ctx, Loc);
217 }
218
219 LLVM_ABI static const MCSymbolRefExpr *create(const MCSymbol *Symbol,
220 Spec specifier, MCContext &Ctx,
221 SMLoc Loc = SMLoc());
222
223 /// @}
224 /// \name Accessors
225 /// @{
226
227 const MCSymbol &getSymbol() const { return *Symbol; }
228
229 // Some targets encode the relocation specifier within SymA using
230 // MCSymbolRefExpr::SubclassData, which is copied to MCValue::Specifier,
231 // though this method is now deprecated.
234
235 /// @}
236
237 static bool classof(const MCExpr *E) {
238 return E->getKind() == MCExpr::SymbolRef;
239 }
240};
241
242/// Unary assembler expressions.
243class MCUnaryExpr : public MCExpr {
244public:
245 enum Opcode {
246 LNot, ///< Logical negation.
247 Minus, ///< Unary minus.
248 Not, ///< Bitwise negation.
249 Plus ///< Unary plus.
250 };
251
252private:
253 const MCExpr *Expr;
254
255 MCUnaryExpr(Opcode Op, const MCExpr *Expr, SMLoc Loc)
256 : MCExpr(MCExpr::Unary, Loc, Op), Expr(Expr) {}
257
258public:
259 /// \name Construction
260 /// @{
261
262 LLVM_ABI static const MCUnaryExpr *
263 create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc());
264
265 static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
266 return create(LNot, Expr, Ctx, Loc);
267 }
268
269 static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
270 return create(Minus, Expr, Ctx, Loc);
271 }
272
273 static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
274 return create(Not, Expr, Ctx, Loc);
275 }
276
277 static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
278 return create(Plus, Expr, Ctx, Loc);
279 }
280
281 /// @}
282 /// \name Accessors
283 /// @{
284
285 /// Get the kind of this unary expression.
286 Opcode getOpcode() const { return (Opcode)getSubclassData(); }
287
288 /// Get the child of this unary expression.
289 const MCExpr *getSubExpr() const { return Expr; }
290
291 /// @}
292
293 static bool classof(const MCExpr *E) {
294 return E->getKind() == MCExpr::Unary;
295 }
296};
297
298/// Binary assembler expressions.
299class MCBinaryExpr : public MCExpr {
300public:
301 enum Opcode {
302 Add, ///< Addition.
303 And, ///< Bitwise and.
304 Div, ///< Signed division.
305 EQ, ///< Equality comparison.
306 GT, ///< Signed greater than comparison (result is either 0 or some
307 ///< target-specific non-zero value)
308 GTE, ///< Signed greater than or equal comparison (result is either 0 or
309 ///< some target-specific non-zero value).
310 LAnd, ///< Logical and.
311 LOr, ///< Logical or.
312 LT, ///< Signed less than comparison (result is either 0 or
313 ///< some target-specific non-zero value).
314 LTE, ///< Signed less than or equal comparison (result is either 0 or
315 ///< some target-specific non-zero value).
316 Mod, ///< Signed remainder.
317 Mul, ///< Multiplication.
318 NE, ///< Inequality comparison.
319 Or, ///< Bitwise or.
320 OrNot, ///< Bitwise or not.
321 Shl, ///< Shift left.
322 AShr, ///< Arithmetic shift right.
323 LShr, ///< Logical shift right.
324 Sub, ///< Subtraction.
325 Xor ///< Bitwise exclusive or.
326 };
327
328private:
329 const MCExpr *LHS, *RHS;
330
331 MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS,
332 SMLoc Loc = SMLoc())
333 : MCExpr(MCExpr::Binary, Loc, Op), LHS(LHS), RHS(RHS) {}
334
335public:
336 /// \name Construction
337 /// @{
338
339 LLVM_ABI static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,
340 const MCExpr *RHS, MCContext &Ctx,
341 SMLoc Loc = SMLoc());
342
343 static const MCBinaryExpr *createAdd(const MCExpr *LHS, const MCExpr *RHS,
344 MCContext &Ctx, SMLoc Loc = SMLoc()) {
345 return create(Add, LHS, RHS, Ctx, Loc);
346 }
347
348 static const MCBinaryExpr *createAnd(const MCExpr *LHS, const MCExpr *RHS,
349 MCContext &Ctx) {
350 return create(And, LHS, RHS, Ctx);
351 }
352
353 static const MCBinaryExpr *createDiv(const MCExpr *LHS, const MCExpr *RHS,
354 MCContext &Ctx) {
355 return create(Div, LHS, RHS, Ctx);
356 }
357
358 static const MCBinaryExpr *createEQ(const MCExpr *LHS, const MCExpr *RHS,
359 MCContext &Ctx) {
360 return create(EQ, LHS, RHS, Ctx);
361 }
362
363 static const MCBinaryExpr *createGT(const MCExpr *LHS, const MCExpr *RHS,
364 MCContext &Ctx) {
365 return create(GT, LHS, RHS, Ctx);
366 }
367
368 static const MCBinaryExpr *createGTE(const MCExpr *LHS, const MCExpr *RHS,
369 MCContext &Ctx) {
370 return create(GTE, LHS, RHS, Ctx);
371 }
372
373 static const MCBinaryExpr *createLAnd(const MCExpr *LHS, const MCExpr *RHS,
374 MCContext &Ctx) {
375 return create(LAnd, LHS, RHS, Ctx);
376 }
377
378 static const MCBinaryExpr *createLOr(const MCExpr *LHS, const MCExpr *RHS,
379 MCContext &Ctx) {
380 return create(LOr, LHS, RHS, Ctx);
381 }
382
383 static const MCBinaryExpr *createLT(const MCExpr *LHS, const MCExpr *RHS,
384 MCContext &Ctx) {
385 return create(LT, LHS, RHS, Ctx);
386 }
387
388 static const MCBinaryExpr *createLTE(const MCExpr *LHS, const MCExpr *RHS,
389 MCContext &Ctx) {
390 return create(LTE, LHS, RHS, Ctx);
391 }
392
393 static const MCBinaryExpr *createMod(const MCExpr *LHS, const MCExpr *RHS,
394 MCContext &Ctx) {
395 return create(Mod, LHS, RHS, Ctx);
396 }
397
398 static const MCBinaryExpr *createMul(const MCExpr *LHS, const MCExpr *RHS,
399 MCContext &Ctx) {
400 return create(Mul, LHS, RHS, Ctx);
401 }
402
403 static const MCBinaryExpr *createNE(const MCExpr *LHS, const MCExpr *RHS,
404 MCContext &Ctx) {
405 return create(NE, LHS, RHS, Ctx);
406 }
407
408 static const MCBinaryExpr *createOr(const MCExpr *LHS, const MCExpr *RHS,
409 MCContext &Ctx) {
410 return create(Or, LHS, RHS, Ctx);
411 }
412
413 static const MCBinaryExpr *createShl(const MCExpr *LHS, const MCExpr *RHS,
414 MCContext &Ctx) {
415 return create(Shl, LHS, RHS, Ctx);
416 }
417
418 static const MCBinaryExpr *createAShr(const MCExpr *LHS, const MCExpr *RHS,
419 MCContext &Ctx) {
420 return create(AShr, LHS, RHS, Ctx);
421 }
422
423 static const MCBinaryExpr *createLShr(const MCExpr *LHS, const MCExpr *RHS,
424 MCContext &Ctx) {
425 return create(LShr, LHS, RHS, Ctx);
426 }
427
428 static const MCBinaryExpr *createSub(const MCExpr *LHS, const MCExpr *RHS,
429 MCContext &Ctx) {
430 return create(Sub, LHS, RHS, Ctx);
431 }
432
433 static const MCBinaryExpr *createXor(const MCExpr *LHS, const MCExpr *RHS,
434 MCContext &Ctx) {
435 return create(Xor, LHS, RHS, Ctx);
436 }
437
438 /// @}
439 /// \name Accessors
440 /// @{
441
442 /// Get the kind of this binary expression.
443 Opcode getOpcode() const { return (Opcode)getSubclassData(); }
444
445 /// Get the left-hand side expression of the binary operator.
446 const MCExpr *getLHS() const { return LHS; }
447
448 /// Get the right-hand side expression of the binary operator.
449 const MCExpr *getRHS() const { return RHS; }
450
451 /// @}
452
453 static bool classof(const MCExpr *E) {
454 return E->getKind() == MCExpr::Binary;
455 }
456};
457
458/// Extension point for target-specific MCExpr subclasses to implement.
459/// This can encode a relocation operator, serving as a replacement for
460/// MCSymbolRefExpr::VariantKind. Ideally, limit this to
461/// top-level use, avoiding its inclusion as a subexpression.
462///
463/// NOTE: All subclasses are required to have trivial destructors because
464/// MCExprs are bump pointer allocated and not destructed.
466 virtual void anchor();
467
468protected:
470 virtual ~MCTargetExpr() = default;
471
472public:
473 virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
475 const MCAssembler *Asm) const = 0;
476 // allow Target Expressions to be checked for equality
477 virtual bool isEqualTo(const MCExpr *x) const { return false; }
478 // This should be set when assigned expressions are not valid ".set"
479 // expressions, e.g. registers, and must be inlined.
480 virtual bool inlineAssignedExpr() const { return false; }
481 virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
482 virtual MCFragment *findAssociatedFragment() const = 0;
483
484 static bool classof(const MCExpr *E) {
485 return E->getKind() == MCExpr::Target;
486 }
487};
488
489/// Extension point for target-specific MCExpr subclasses with a relocation
490/// specifier, serving as a replacement for MCSymbolRefExpr::VariantKind.
491/// Limit this to top-level use, avoiding its inclusion as a subexpression.
492///
493/// NOTE: All subclasses are required to have trivial destructors because
494/// MCExprs are bump pointer allocated and not destructed.
496protected:
497 const MCExpr *Expr;
498
499 explicit MCSpecifierExpr(const MCExpr *Expr, Spec S, SMLoc Loc = SMLoc())
500 : MCExpr(Specifier, Loc, S), Expr(Expr) {}
501
502public:
503 static const MCSpecifierExpr *create(const MCExpr *Expr, Spec S,
504 MCContext &Ctx, SMLoc Loc = SMLoc());
505 static const MCSpecifierExpr *create(const MCSymbol *Sym, Spec S,
506 MCContext &Ctx, SMLoc Loc = SMLoc());
507
508 Spec getSpecifier() const { return getSubclassData(); }
509 const MCExpr *getSubExpr() const { return Expr; }
510
511 static bool classof(const MCExpr *E) {
512 return E->getKind() == MCExpr::Specifier;
513 }
514};
515
516} // end namespace llvm
517
518#endif // LLVM_MC_MCEXPR_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the DenseMap class.
Symbol * Sym
Definition: ELF_riscv.cpp:479
raw_pwrite_stream & OS
Value * RHS
Value * LHS
This class represents an Operation in the Expression.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
Binary assembler expressions.
Definition: MCExpr.h:299
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:446
static const MCBinaryExpr * createEQ(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:358
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:423
static const MCBinaryExpr * createLAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:373
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:343
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:449
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:433
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:348
static bool classof(const MCExpr *E)
Definition: MCExpr.h:453
static const MCBinaryExpr * createLT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:383
Opcode getOpcode() const
Get the kind of this binary expression.
Definition: MCExpr.h:443
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:408
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:393
static const MCBinaryExpr * createLOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:378
static const MCBinaryExpr * createNE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:403
static const MCBinaryExpr * createGTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:368
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:398
static const MCBinaryExpr * createLTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:388
static const MCBinaryExpr * createAShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:418
static const MCBinaryExpr * createGT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:363
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:353
static LLVM_ABI const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.cpp:201
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:413
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:428
@ Div
Signed division.
Definition: MCExpr.h:304
@ Shl
Shift left.
Definition: MCExpr.h:321
@ AShr
Arithmetic shift right.
Definition: MCExpr.h:322
@ LShr
Logical shift right.
Definition: MCExpr.h:323
@ GTE
Signed greater than or equal comparison (result is either 0 or some target-specific non-zero value).
Definition: MCExpr.h:308
@ EQ
Equality comparison.
Definition: MCExpr.h:305
@ Sub
Subtraction.
Definition: MCExpr.h:324
@ Mul
Multiplication.
Definition: MCExpr.h:317
@ GT
Signed greater than comparison (result is either 0 or some target-specific non-zero value)
Definition: MCExpr.h:306
@ Mod
Signed remainder.
Definition: MCExpr.h:316
@ And
Bitwise and.
Definition: MCExpr.h:303
@ Or
Bitwise or.
Definition: MCExpr.h:319
@ Xor
Bitwise exclusive or.
Definition: MCExpr.h:325
@ OrNot
Bitwise or not.
Definition: MCExpr.h:320
@ LAnd
Logical and.
Definition: MCExpr.h:310
@ LOr
Logical or.
Definition: MCExpr.h:311
@ LT
Signed less than comparison (result is either 0 or some target-specific non-zero value).
Definition: MCExpr.h:312
@ Add
Addition.
Definition: MCExpr.h:302
@ LTE
Signed less than or equal comparison (result is either 0 or some target-specific non-zero value).
Definition: MCExpr.h:314
@ NE
Inequality comparison.
Definition: MCExpr.h:318
static bool classof(const MCExpr *E)
Definition: MCExpr.h:180
bool useHexFormat() const
Definition: MCExpr.h:176
unsigned getSizeInBytes() const
Definition: MCExpr.h:172
int64_t getValue() const
Definition: MCExpr.h:171
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:212
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
LLVM_ABI bool evaluateAsValue(MCValue &Res, const MCAssembler &Asm) const
Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables.
Definition: MCExpr.cpp:453
MCExpr & operator=(const MCExpr &)=delete
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
Definition: MCExpr.cpp:450
MCExpr(ExprKind Kind, SMLoc Loc, unsigned SubclassData=0)
Definition: MCExpr.h:67
@ Unary
Unary expressions.
Definition: MCExpr.h:44
@ Constant
Constant expressions.
Definition: MCExpr.h:42
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:43
@ Specifier
Expression with a relocation specifier.
Definition: MCExpr.h:45
@ Binary
Binary expressions.
Definition: MCExpr.h:41
MCExpr(const MCExpr &)=delete
static LLVM_ABI bool evaluateSymbolicAdd(const MCAssembler *, bool, const MCValue &, const MCValue &, MCValue &)
Definition: MCExpr.cpp:407
LLVM_ABI bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
Definition: MCExpr.cpp:250
unsigned getSubclassData() const
Definition: MCExpr.h:76
LLVM_ABI MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:692
LLVM_ABI bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, bool InSet) const
Definition: MCExpr.cpp:457
LLVM_ABI void dump() const
Definition: MCExpr.cpp:193
ExprKind getKind() const
Definition: MCExpr.h:85
SMLoc getLoc() const
Definition: MCExpr.h:86
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:40
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
Definition: MCExpr.h:495
const MCExpr * getSubExpr() const
Definition: MCExpr.h:509
static bool classof(const MCExpr *E)
Definition: MCExpr.h:511
const MCExpr * Expr
Definition: MCExpr.h:497
MCSpecifierExpr(const MCExpr *Expr, Spec S, SMLoc Loc=SMLoc())
Definition: MCExpr.h:499
Spec getSpecifier() const
Definition: MCExpr.h:508
Streaming machine code generation interface.
Definition: MCStreamer.h:220
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:190
const MCSymbol & getSymbol() const
Definition: MCExpr.h:227
static bool classof(const MCExpr *E)
Definition: MCExpr.h:237
uint16_t getSpecifier() const
Definition: MCExpr.h:233
VariantKind getKind() const
Definition: MCExpr.h:232
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:214
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
Extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:465
static bool classof(const MCExpr *E)
Definition: MCExpr.h:484
virtual void visitUsedExpr(MCStreamer &Streamer) const =0
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const =0
virtual MCFragment * findAssociatedFragment() const =0
virtual bool isEqualTo(const MCExpr *x) const
Definition: MCExpr.h:477
virtual bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const =0
virtual bool inlineAssignedExpr() const
Definition: MCExpr.h:480
virtual ~MCTargetExpr()=default
Unary assembler expressions.
Definition: MCExpr.h:243
Opcode getOpcode() const
Get the kind of this unary expression.
Definition: MCExpr.h:286
static bool classof(const MCExpr *E)
Definition: MCExpr.h:293
static LLVM_ABI const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.cpp:207
static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:265
@ Minus
Unary minus.
Definition: MCExpr.h:247
@ Plus
Unary plus.
Definition: MCExpr.h:249
@ Not
Bitwise negation.
Definition: MCExpr.h:248
@ LNot
Logical negation.
Definition: MCExpr.h:246
const MCExpr * getSubExpr() const
Get the child of this unary expression.
Definition: MCExpr.h:289
static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:277
static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:273
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:269
Represents a location in source code.
Definition: SMLoc.h:23
Target - Wrapper for Target specific information.
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
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
DWARFExpression::Operation Op
Matching combinators.