LLVM  10.0.0svn
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"
13 #include "llvm/Support/SMLoc.h"
14 #include <cstdint>
15 
16 namespace llvm {
17 
18 class MCAsmInfo;
19 class MCAsmLayout;
20 class MCAssembler;
21 class MCContext;
22 class MCFixup;
23 class MCFragment;
24 class MCSection;
25 class MCStreamer;
26 class MCSymbol;
27 class MCValue;
28 class raw_ostream;
29 class StringRef;
30 
32 
33 /// Base class for the full range of assembler expressions which are
34 /// needed for parsing.
35 class MCExpr {
36 public:
37  enum ExprKind {
38  Binary, ///< Binary expressions.
39  Constant, ///< Constant expressions.
40  SymbolRef, ///< References to labels and assigned expressions.
41  Unary, ///< Unary expressions.
42  Target ///< Target specific expression.
43  };
44 
45 private:
46  ExprKind Kind;
47  SMLoc Loc;
48 
49  bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
50  const MCAsmLayout *Layout,
51  const SectionAddrMap *Addrs, bool InSet) const;
52 
53 protected:
54  explicit MCExpr(ExprKind Kind, SMLoc Loc) : Kind(Kind), Loc(Loc) {}
55 
57  const MCAsmLayout *Layout,
58  const MCFixup *Fixup,
59  const SectionAddrMap *Addrs, bool InSet) const;
60 
61 public:
62  MCExpr(const MCExpr &) = delete;
63  MCExpr &operator=(const MCExpr &) = delete;
64 
65  /// \name Accessors
66  /// @{
67 
68  ExprKind getKind() const { return Kind; }
69  SMLoc getLoc() const { return Loc; }
70 
71  /// @}
72  /// \name Utility Methods
73  /// @{
74 
75  void print(raw_ostream &OS, const MCAsmInfo *MAI,
76  bool InParens = false) const;
77  void dump() const;
78 
79  /// @}
80  /// \name Expression Evaluation
81  /// @{
82 
83  /// Try to evaluate the expression to an absolute value.
84  ///
85  /// \param Res - The absolute value, if evaluation succeeds.
86  /// \param Layout - The assembler layout object to use for evaluating symbol
87  /// values. If not given, then only non-symbolic expressions will be
88  /// evaluated.
89  /// \return - True on success.
90  bool evaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout,
91  const SectionAddrMap &Addrs) const;
92  bool evaluateAsAbsolute(int64_t &Res) const;
93  bool evaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const;
94  bool evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const;
95  bool evaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
96 
97  bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const;
98 
99  /// Try to evaluate the expression to a relocatable value, i.e. an
100  /// expression of the fixed form (a - b + constant).
101  ///
102  /// \param Res - The relocatable value, if evaluation succeeds.
103  /// \param Layout - The assembler layout object to use for evaluating values.
104  /// \param Fixup - The Fixup object if available.
105  /// \return - True on success.
106  bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout,
107  const MCFixup *Fixup) const;
108 
109  /// Try to evaluate the expression to the form (a - b + constant) where
110  /// neither a nor b are variables.
111  ///
112  /// This is a more aggressive variant of evaluateAsRelocatable. The intended
113  /// use is for when relocations are not available, like the .size directive.
114  bool evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const;
115 
116  /// Find the "associated section" for this expression, which is
117  /// currently defined as the absolute section for constants, or
118  /// otherwise the section associated with the first defined symbol in the
119  /// expression.
121 
122  /// @}
123 };
124 
125 inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
126  E.print(OS, nullptr);
127  return OS;
128 }
129 
130 //// Represent a constant integer expression.
131 class MCConstantExpr : public MCExpr {
132  int64_t Value;
133  bool PrintInHex = false;
134 
135  explicit MCConstantExpr(int64_t Value)
136  : MCExpr(MCExpr::Constant, SMLoc()), Value(Value) {}
137 
138  MCConstantExpr(int64_t Value, bool PrintInHex)
139  : MCExpr(MCExpr::Constant, SMLoc()), Value(Value),
140  PrintInHex(PrintInHex) {}
141 
142 public:
143  /// \name Construction
144  /// @{
145 
146  static const MCConstantExpr *create(int64_t Value, MCContext &Ctx,
147  bool PrintInHex = false);
148 
149  /// @}
150  /// \name Accessors
151  /// @{
152 
153  int64_t getValue() const { return Value; }
154 
155  bool useHexFormat() const { return PrintInHex; }
156 
157  /// @}
158 
159  static bool classof(const MCExpr *E) {
160  return E->getKind() == MCExpr::Constant;
161  }
162 };
163 
164 /// Represent a reference to a symbol from inside an expression.
165 ///
166 /// A symbol reference in an expression may be a use of a label, a use of an
167 /// assembler variable (defined constant), or constitute an implicit definition
168 /// of the symbol as external.
169 class MCSymbolRefExpr : public MCExpr {
170 public:
171  enum VariantKind : uint16_t {
174 
189  VK_TLSCALL, // symbol(tlscall)
190  VK_TLSDESC, // symbol(tlsdesc)
191  VK_TLVP, // Mach-O thread local variable relocations
199  VK_SIZE, // symbol@SIZE
200  VK_WEAKREF, // The link between the symbols in .weakref foo, bar
201 
203 
209  VK_ARM_SBREL, // symbol(sbrel)
210  VK_ARM_TLSLDO, // symbol(tlsldo)
212 
220 
221  VK_PPC_LO, // symbol@l
222  VK_PPC_HI, // symbol@h
223  VK_PPC_HA, // symbol@ha
224  VK_PPC_HIGH, // symbol@high
225  VK_PPC_HIGHA, // symbol@higha
226  VK_PPC_HIGHER, // symbol@higher
227  VK_PPC_HIGHERA, // symbol@highera
228  VK_PPC_HIGHEST, // symbol@highest
229  VK_PPC_HIGHESTA, // symbol@highesta
230  VK_PPC_GOT_LO, // symbol@got@l
231  VK_PPC_GOT_HI, // symbol@got@h
232  VK_PPC_GOT_HA, // symbol@got@ha
233  VK_PPC_TOCBASE, // symbol@tocbase
234  VK_PPC_TOC, // symbol@toc
235  VK_PPC_TOC_LO, // symbol@toc@l
236  VK_PPC_TOC_HI, // symbol@toc@h
237  VK_PPC_TOC_HA, // symbol@toc@ha
238  VK_PPC_U, // symbol@u
239  VK_PPC_L, // symbol@l
240  VK_PPC_DTPMOD, // symbol@dtpmod
241  VK_PPC_TPREL_LO, // symbol@tprel@l
242  VK_PPC_TPREL_HI, // symbol@tprel@h
243  VK_PPC_TPREL_HA, // symbol@tprel@ha
244  VK_PPC_TPREL_HIGH, // symbol@tprel@high
245  VK_PPC_TPREL_HIGHA, // symbol@tprel@higha
246  VK_PPC_TPREL_HIGHER, // symbol@tprel@higher
247  VK_PPC_TPREL_HIGHERA, // symbol@tprel@highera
248  VK_PPC_TPREL_HIGHEST, // symbol@tprel@highest
249  VK_PPC_TPREL_HIGHESTA, // symbol@tprel@highesta
250  VK_PPC_DTPREL_LO, // symbol@dtprel@l
251  VK_PPC_DTPREL_HI, // symbol@dtprel@h
252  VK_PPC_DTPREL_HA, // symbol@dtprel@ha
253  VK_PPC_DTPREL_HIGH, // symbol@dtprel@high
254  VK_PPC_DTPREL_HIGHA, // symbol@dtprel@higha
255  VK_PPC_DTPREL_HIGHER, // symbol@dtprel@higher
256  VK_PPC_DTPREL_HIGHERA, // symbol@dtprel@highera
257  VK_PPC_DTPREL_HIGHEST, // symbol@dtprel@highest
258  VK_PPC_DTPREL_HIGHESTA,// symbol@dtprel@highesta
259  VK_PPC_GOT_TPREL, // symbol@got@tprel
260  VK_PPC_GOT_TPREL_LO, // symbol@got@tprel@l
261  VK_PPC_GOT_TPREL_HI, // symbol@got@tprel@h
262  VK_PPC_GOT_TPREL_HA, // symbol@got@tprel@ha
263  VK_PPC_GOT_DTPREL, // symbol@got@dtprel
264  VK_PPC_GOT_DTPREL_LO, // symbol@got@dtprel@l
265  VK_PPC_GOT_DTPREL_HI, // symbol@got@dtprel@h
266  VK_PPC_GOT_DTPREL_HA, // symbol@got@dtprel@ha
267  VK_PPC_TLS, // symbol@tls
268  VK_PPC_GOT_TLSGD, // symbol@got@tlsgd
269  VK_PPC_GOT_TLSGD_LO, // symbol@got@tlsgd@l
270  VK_PPC_GOT_TLSGD_HI, // symbol@got@tlsgd@h
271  VK_PPC_GOT_TLSGD_HA, // symbol@got@tlsgd@ha
272  VK_PPC_TLSGD, // symbol@tlsgd
273  VK_PPC_GOT_TLSLD, // symbol@got@tlsld
274  VK_PPC_GOT_TLSLD_LO, // symbol@got@tlsld@l
275  VK_PPC_GOT_TLSLD_HI, // symbol@got@tlsld@h
276  VK_PPC_GOT_TLSLD_HA, // symbol@got@tlsld@ha
277  VK_PPC_TLSLD, // symbol@tlsld
278  VK_PPC_LOCAL, // symbol@local
279 
280  VK_COFF_IMGREL32, // symbol@imgrel (image-relative)
281 
292 
293  VK_WASM_TYPEINDEX, // Reference to a symbol's type (signature)
294  VK_WASM_MBREL, // Memory address relative to memory base
295  VK_WASM_TBREL, // Table index relative to table bare
296 
297  VK_AMDGPU_GOTPCREL32_LO, // symbol@gotpcrel32@lo
298  VK_AMDGPU_GOTPCREL32_HI, // symbol@gotpcrel32@hi
299  VK_AMDGPU_REL32_LO, // symbol@rel32@lo
300  VK_AMDGPU_REL32_HI, // symbol@rel32@hi
301  VK_AMDGPU_REL64, // symbol@rel64
302  VK_AMDGPU_ABS32_LO, // symbol@abs32@lo
303  VK_AMDGPU_ABS32_HI, // symbol@abs32@hi
304 
306  VK_DTPREL
307  };
308 
309 private:
310  /// The symbol reference modifier.
311  const VariantKind Kind;
312 
313  /// Specifies how the variant kind should be printed.
314  const unsigned UseParensForSymbolVariant : 1;
315 
316  // FIXME: Remove this bit.
317  const unsigned HasSubsectionsViaSymbols : 1;
318 
319  /// The symbol being referenced.
320  const MCSymbol *Symbol;
321 
322  explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
323  const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
324 
325 public:
326  /// \name Construction
327  /// @{
328 
329  static const MCSymbolRefExpr *create(const MCSymbol *Symbol, MCContext &Ctx) {
330  return MCSymbolRefExpr::create(Symbol, VK_None, Ctx);
331  }
332 
333  static const MCSymbolRefExpr *create(const MCSymbol *Symbol, VariantKind Kind,
334  MCContext &Ctx, SMLoc Loc = SMLoc());
335  static const MCSymbolRefExpr *create(StringRef Name, VariantKind Kind,
336  MCContext &Ctx);
337 
338  /// @}
339  /// \name Accessors
340  /// @{
341 
342  const MCSymbol &getSymbol() const { return *Symbol; }
343 
344  VariantKind getKind() const { return Kind; }
345 
346  void printVariantKind(raw_ostream &OS) const;
347 
348  bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
349 
350  /// @}
351  /// \name Static Utility Functions
352  /// @{
353 
354  static StringRef getVariantKindName(VariantKind Kind);
355 
356  static VariantKind getVariantKindForName(StringRef Name);
357 
358  /// @}
359 
360  static bool classof(const MCExpr *E) {
361  return E->getKind() == MCExpr::SymbolRef;
362  }
363 };
364 
365 /// Unary assembler expressions.
366 class MCUnaryExpr : public MCExpr {
367 public:
368  enum Opcode {
369  LNot, ///< Logical negation.
370  Minus, ///< Unary minus.
371  Not, ///< Bitwise negation.
372  Plus ///< Unary plus.
373  };
374 
375 private:
376  Opcode Op;
377  const MCExpr *Expr;
378 
379  MCUnaryExpr(Opcode Op, const MCExpr *Expr, SMLoc Loc)
380  : MCExpr(MCExpr::Unary, Loc), Op(Op), Expr(Expr) {}
381 
382 public:
383  /// \name Construction
384  /// @{
385 
386  static const MCUnaryExpr *create(Opcode Op, const MCExpr *Expr,
387  MCContext &Ctx, SMLoc Loc = SMLoc());
388 
389  static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
390  return create(LNot, Expr, Ctx, Loc);
391  }
392 
393  static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
394  return create(Minus, Expr, Ctx, Loc);
395  }
396 
397  static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
398  return create(Not, Expr, Ctx, Loc);
399  }
400 
401  static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
402  return create(Plus, Expr, Ctx, Loc);
403  }
404 
405  /// @}
406  /// \name Accessors
407  /// @{
408 
409  /// Get the kind of this unary expression.
410  Opcode getOpcode() const { return Op; }
411 
412  /// Get the child of this unary expression.
413  const MCExpr *getSubExpr() const { return Expr; }
414 
415  /// @}
416 
417  static bool classof(const MCExpr *E) {
418  return E->getKind() == MCExpr::Unary;
419  }
420 };
421 
422 /// Binary assembler expressions.
423 class MCBinaryExpr : public MCExpr {
424 public:
425  enum Opcode {
426  Add, ///< Addition.
427  And, ///< Bitwise and.
428  Div, ///< Signed division.
429  EQ, ///< Equality comparison.
430  GT, ///< Signed greater than comparison (result is either 0 or some
431  ///< target-specific non-zero value)
432  GTE, ///< Signed greater than or equal comparison (result is either 0 or
433  ///< some target-specific non-zero value).
434  LAnd, ///< Logical and.
435  LOr, ///< Logical or.
436  LT, ///< Signed less than comparison (result is either 0 or
437  ///< some target-specific non-zero value).
438  LTE, ///< Signed less than or equal comparison (result is either 0 or
439  ///< some target-specific non-zero value).
440  Mod, ///< Signed remainder.
441  Mul, ///< Multiplication.
442  NE, ///< Inequality comparison.
443  Or, ///< Bitwise or.
444  Shl, ///< Shift left.
445  AShr, ///< Arithmetic shift right.
446  LShr, ///< Logical shift right.
447  Sub, ///< Subtraction.
448  Xor ///< Bitwise exclusive or.
449  };
450 
451 private:
452  Opcode Op;
453  const MCExpr *LHS, *RHS;
454 
455  MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS,
456  SMLoc Loc = SMLoc())
457  : MCExpr(MCExpr::Binary, Loc), Op(Op), LHS(LHS), RHS(RHS) {}
458 
459 public:
460  /// \name Construction
461  /// @{
462 
463  static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,
464  const MCExpr *RHS, MCContext &Ctx,
465  SMLoc Loc = SMLoc());
466 
467  static const MCBinaryExpr *createAdd(const MCExpr *LHS, const MCExpr *RHS,
468  MCContext &Ctx) {
469  return create(Add, LHS, RHS, Ctx);
470  }
471 
472  static const MCBinaryExpr *createAnd(const MCExpr *LHS, const MCExpr *RHS,
473  MCContext &Ctx) {
474  return create(And, LHS, RHS, Ctx);
475  }
476 
477  static const MCBinaryExpr *createDiv(const MCExpr *LHS, const MCExpr *RHS,
478  MCContext &Ctx) {
479  return create(Div, LHS, RHS, Ctx);
480  }
481 
482  static const MCBinaryExpr *createEQ(const MCExpr *LHS, const MCExpr *RHS,
483  MCContext &Ctx) {
484  return create(EQ, LHS, RHS, Ctx);
485  }
486 
487  static const MCBinaryExpr *createGT(const MCExpr *LHS, const MCExpr *RHS,
488  MCContext &Ctx) {
489  return create(GT, LHS, RHS, Ctx);
490  }
491 
492  static const MCBinaryExpr *createGTE(const MCExpr *LHS, const MCExpr *RHS,
493  MCContext &Ctx) {
494  return create(GTE, LHS, RHS, Ctx);
495  }
496 
497  static const MCBinaryExpr *createLAnd(const MCExpr *LHS, const MCExpr *RHS,
498  MCContext &Ctx) {
499  return create(LAnd, LHS, RHS, Ctx);
500  }
501 
502  static const MCBinaryExpr *createLOr(const MCExpr *LHS, const MCExpr *RHS,
503  MCContext &Ctx) {
504  return create(LOr, LHS, RHS, Ctx);
505  }
506 
507  static const MCBinaryExpr *createLT(const MCExpr *LHS, const MCExpr *RHS,
508  MCContext &Ctx) {
509  return create(LT, LHS, RHS, Ctx);
510  }
511 
512  static const MCBinaryExpr *createLTE(const MCExpr *LHS, const MCExpr *RHS,
513  MCContext &Ctx) {
514  return create(LTE, LHS, RHS, Ctx);
515  }
516 
517  static const MCBinaryExpr *createMod(const MCExpr *LHS, const MCExpr *RHS,
518  MCContext &Ctx) {
519  return create(Mod, LHS, RHS, Ctx);
520  }
521 
522  static const MCBinaryExpr *createMul(const MCExpr *LHS, const MCExpr *RHS,
523  MCContext &Ctx) {
524  return create(Mul, LHS, RHS, Ctx);
525  }
526 
527  static const MCBinaryExpr *createNE(const MCExpr *LHS, const MCExpr *RHS,
528  MCContext &Ctx) {
529  return create(NE, LHS, RHS, Ctx);
530  }
531 
532  static const MCBinaryExpr *createOr(const MCExpr *LHS, const MCExpr *RHS,
533  MCContext &Ctx) {
534  return create(Or, LHS, RHS, Ctx);
535  }
536 
537  static const MCBinaryExpr *createShl(const MCExpr *LHS, const MCExpr *RHS,
538  MCContext &Ctx) {
539  return create(Shl, LHS, RHS, Ctx);
540  }
541 
542  static const MCBinaryExpr *createAShr(const MCExpr *LHS, const MCExpr *RHS,
543  MCContext &Ctx) {
544  return create(AShr, LHS, RHS, Ctx);
545  }
546 
547  static const MCBinaryExpr *createLShr(const MCExpr *LHS, const MCExpr *RHS,
548  MCContext &Ctx) {
549  return create(LShr, LHS, RHS, Ctx);
550  }
551 
552  static const MCBinaryExpr *createSub(const MCExpr *LHS, const MCExpr *RHS,
553  MCContext &Ctx) {
554  return create(Sub, LHS, RHS, Ctx);
555  }
556 
557  static const MCBinaryExpr *createXor(const MCExpr *LHS, const MCExpr *RHS,
558  MCContext &Ctx) {
559  return create(Xor, LHS, RHS, Ctx);
560  }
561 
562  /// @}
563  /// \name Accessors
564  /// @{
565 
566  /// Get the kind of this binary expression.
567  Opcode getOpcode() const { return Op; }
568 
569  /// Get the left-hand side expression of the binary operator.
570  const MCExpr *getLHS() const { return LHS; }
571 
572  /// Get the right-hand side expression of the binary operator.
573  const MCExpr *getRHS() const { return RHS; }
574 
575  /// @}
576 
577  static bool classof(const MCExpr *E) {
578  return E->getKind() == MCExpr::Binary;
579  }
580 };
581 
582 /// This is an extension point for target-specific MCExpr subclasses to
583 /// implement.
584 ///
585 /// NOTE: All subclasses are required to have trivial destructors because
586 /// MCExprs are bump pointer allocated and not destructed.
587 class MCTargetExpr : public MCExpr {
588  virtual void anchor();
589 
590 protected:
592  virtual ~MCTargetExpr() = default;
593 
594 public:
595  virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
596  virtual bool evaluateAsRelocatableImpl(MCValue &Res,
597  const MCAsmLayout *Layout,
598  const MCFixup *Fixup) const = 0;
599  // allow Target Expressions to be checked for equality
600  virtual bool isEqualTo(const MCExpr *x) const { return false; }
601  // This should be set when assigned expressions are not valid ".set"
602  // expressions, e.g. registers, and must be inlined.
603  virtual bool inlineAssignedExpr() const { return false; }
604  virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
605  virtual MCFragment *findAssociatedFragment() const = 0;
606 
607  virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const = 0;
608 
609  static bool classof(const MCExpr *E) {
610  return E->getKind() == MCExpr::Target;
611  }
612 };
613 
614 } // end namespace llvm
615 
616 #endif // LLVM_MC_MCEXPR_H
static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:389
static const MCBinaryExpr * createGT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:487
static const MCBinaryExpr * createEQ(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:482
Bitwise negation.
Definition: MCExpr.h:371
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:329
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This represents an "assembler immediate".
Definition: MCValue.h:39
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
VariantKind getKind() const
Definition: MCExpr.h:344
Bitwise and.
Definition: MCExpr.h:427
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Multiplication.
Definition: MCExpr.h:441
Opcode getOpcode() const
Get the kind of this unary expression.
Definition: MCExpr.h:410
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:570
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:472
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:522
Equality comparison.
Definition: MCExpr.h:429
Bitwise or.
Definition: MCExpr.h:443
SMLoc getLoc() const
Definition: MCExpr.h:69
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:77
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:557
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:477
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:587
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:169
static const MCBinaryExpr * createAShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:542
Context object for machine code objects.
Definition: MCContext.h:65
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:537
virtual bool inlineAssignedExpr() const
Definition: MCExpr.h:603
static const MCBinaryExpr * createLOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:502
Arithmetic shift right.
Definition: MCExpr.h:445
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:552
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Definition: MCExpr.cpp:669
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:573
Logical or.
Definition: MCExpr.h:435
Signed remainder.
Definition: MCExpr.h:440
static bool classof(const MCExpr *E)
Definition: MCExpr.h:159
Unary assembler expressions.
Definition: MCExpr.h:366
void dump() const
Definition: MCExpr.cpp:150
Signed division.
Definition: MCExpr.h:428
#define EQ(a, b)
Definition: regexec.c:112
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:467
bool useHexFormat() const
Definition: MCExpr.h:155
Unary expressions.
Definition: MCExpr.h:41
Shift left.
Definition: MCExpr.h:444
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
int64_t getValue() const
Definition: MCExpr.h:153
static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:401
Streaming machine code generation interface.
Definition: MCStreamer.h:196
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const
Definition: MCExpr.cpp:484
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:42
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:532
Logical negation.
Definition: MCExpr.h:369
Logical and.
Definition: MCExpr.h:434
Binary assembler expressions.
Definition: MCExpr.h:423
bool hasSubsectionsViaSymbols() const
Definition: MCExpr.h:348
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:547
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:393
PowerPC TLS Dynamic Call Fixup
static bool classof(const MCExpr *E)
Definition: MCExpr.h:577
const MCSymbol & getSymbol() const
Definition: MCExpr.h:342
ExprKind getKind() const
Definition: MCExpr.h:68
static const MCBinaryExpr * createLT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:507
static bool classof(const MCExpr *E)
Definition: MCExpr.h:609
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const
Definition: MCExpr.cpp:696
Inequality comparison.
Definition: MCExpr.h:442
MCExpr & operator=(const MCExpr &)=delete
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:889
The access may modify the value stored in memory.
Target - Wrapper for Target specific information.
static const MCBinaryExpr * createLAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:497
Logical shift right.
Definition: MCExpr.h:446
static const MCBinaryExpr * createNE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:527
static const MCBinaryExpr * createLTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:512
static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:397
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:517
References to labels and assigned expressions.
Definition: MCExpr.h:40
Unary minus.
Definition: MCExpr.h:370
bool evaluateAsValue(MCValue &Res, const MCAsmLayout &Layout) const
Try to evaluate the expression to the form (a - b + constant) where neither a nor b are variables...
Definition: MCExpr.cpp:677
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:2047
virtual bool isEqualTo(const MCExpr *x) const
Definition: MCExpr.h:600
static bool classof(const MCExpr *E)
Definition: MCExpr.h:417
Opcode getOpcode() const
Get the kind of this binary expression.
Definition: MCExpr.h:567
const MCExpr * getSubExpr() const
Get the child of this unary expression.
Definition: MCExpr.h:413
Constant expressions.
Definition: MCExpr.h:39
Binary expressions.
Definition: MCExpr.h:38
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Subtraction.
Definition: MCExpr.h:447
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Target specific expression.
Definition: MCExpr.h:42
static bool classof(const MCExpr *E)
Definition: MCExpr.h:360
Represents a location in source code.
Definition: SMLoc.h:23
MCExpr(ExprKind Kind, SMLoc Loc)
Definition: MCExpr.h:54
static const MCBinaryExpr * createGTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:492