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