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