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 
138  explicit MCConstantExpr(int64_t Value)
139  : MCExpr(MCExpr::Constant, SMLoc()), Value(Value) {}
140 
141 public:
142  /// \name Construction
143  /// @{
144 
145  static const MCConstantExpr *create(int64_t Value, MCContext &Ctx);
146 
147  /// @}
148  /// \name Accessors
149  /// @{
150 
151  int64_t getValue() const { return Value; }
152 
153  /// @}
154 
155  static bool classof(const MCExpr *E) {
156  return E->getKind() == MCExpr::Constant;
157  }
158 };
159 
160 /// Represent a reference to a symbol from inside an expression.
161 ///
162 /// A symbol reference in an expression may be a use of a label, a use of an
163 /// assembler variable (defined constant), or constitute an implicit definition
164 /// of the symbol as external.
165 class MCSymbolRefExpr : public MCExpr {
166 public:
167  enum VariantKind : uint16_t {
170 
185  VK_TLSCALL, // symbol(tlscall)
186  VK_TLSDESC, // symbol(tlsdesc)
187  VK_TLVP, // Mach-O thread local variable relocations
195  VK_SIZE, // symbol@SIZE
196  VK_WEAKREF, // The link between the symbols in .weakref foo, bar
197 
199 
205  VK_ARM_SBREL, // symbol(sbrel)
206  VK_ARM_TLSLDO, // symbol(tlsldo)
208 
216 
217  VK_PPC_LO, // symbol@l
218  VK_PPC_HI, // symbol@h
219  VK_PPC_HA, // symbol@ha
220  VK_PPC_HIGH, // symbol@high
221  VK_PPC_HIGHA, // symbol@higha
222  VK_PPC_HIGHER, // symbol@higher
223  VK_PPC_HIGHERA, // symbol@highera
224  VK_PPC_HIGHEST, // symbol@highest
225  VK_PPC_HIGHESTA, // symbol@highesta
226  VK_PPC_GOT_LO, // symbol@got@l
227  VK_PPC_GOT_HI, // symbol@got@h
228  VK_PPC_GOT_HA, // symbol@got@ha
229  VK_PPC_TOCBASE, // symbol@tocbase
230  VK_PPC_TOC, // symbol@toc
231  VK_PPC_TOC_LO, // symbol@toc@l
232  VK_PPC_TOC_HI, // symbol@toc@h
233  VK_PPC_TOC_HA, // symbol@toc@ha
234  VK_PPC_DTPMOD, // symbol@dtpmod
235  VK_PPC_TPREL_LO, // symbol@tprel@l
236  VK_PPC_TPREL_HI, // symbol@tprel@h
237  VK_PPC_TPREL_HA, // symbol@tprel@ha
238  VK_PPC_TPREL_HIGH, // symbol@tprel@high
239  VK_PPC_TPREL_HIGHA, // symbol@tprel@higha
240  VK_PPC_TPREL_HIGHER, // symbol@tprel@higher
241  VK_PPC_TPREL_HIGHERA, // symbol@tprel@highera
242  VK_PPC_TPREL_HIGHEST, // symbol@tprel@highest
243  VK_PPC_TPREL_HIGHESTA, // symbol@tprel@highesta
244  VK_PPC_DTPREL_LO, // symbol@dtprel@l
245  VK_PPC_DTPREL_HI, // symbol@dtprel@h
246  VK_PPC_DTPREL_HA, // symbol@dtprel@ha
247  VK_PPC_DTPREL_HIGH, // symbol@dtprel@high
248  VK_PPC_DTPREL_HIGHA, // symbol@dtprel@higha
249  VK_PPC_DTPREL_HIGHER, // symbol@dtprel@higher
250  VK_PPC_DTPREL_HIGHERA, // symbol@dtprel@highera
251  VK_PPC_DTPREL_HIGHEST, // symbol@dtprel@highest
252  VK_PPC_DTPREL_HIGHESTA,// symbol@dtprel@highesta
253  VK_PPC_GOT_TPREL, // symbol@got@tprel
254  VK_PPC_GOT_TPREL_LO, // symbol@got@tprel@l
255  VK_PPC_GOT_TPREL_HI, // symbol@got@tprel@h
256  VK_PPC_GOT_TPREL_HA, // symbol@got@tprel@ha
257  VK_PPC_GOT_DTPREL, // symbol@got@dtprel
258  VK_PPC_GOT_DTPREL_LO, // symbol@got@dtprel@l
259  VK_PPC_GOT_DTPREL_HI, // symbol@got@dtprel@h
260  VK_PPC_GOT_DTPREL_HA, // symbol@got@dtprel@ha
261  VK_PPC_TLS, // symbol@tls
262  VK_PPC_GOT_TLSGD, // symbol@got@tlsgd
263  VK_PPC_GOT_TLSGD_LO, // symbol@got@tlsgd@l
264  VK_PPC_GOT_TLSGD_HI, // symbol@got@tlsgd@h
265  VK_PPC_GOT_TLSGD_HA, // symbol@got@tlsgd@ha
266  VK_PPC_TLSGD, // symbol@tlsgd
267  VK_PPC_GOT_TLSLD, // symbol@got@tlsld
268  VK_PPC_GOT_TLSLD_LO, // symbol@got@tlsld@l
269  VK_PPC_GOT_TLSLD_HI, // symbol@got@tlsld@h
270  VK_PPC_GOT_TLSLD_HA, // symbol@got@tlsld@ha
271  VK_PPC_TLSLD, // symbol@tlsld
272  VK_PPC_LOCAL, // symbol@local
273 
274  VK_COFF_IMGREL32, // symbol@imgrel (image-relative)
275 
286 
287  VK_WebAssembly_TYPEINDEX,// Reference to a symbol's type (signature)
288 
289  VK_AMDGPU_GOTPCREL32_LO, // symbol@gotpcrel32@lo
290  VK_AMDGPU_GOTPCREL32_HI, // symbol@gotpcrel32@hi
291  VK_AMDGPU_REL32_LO, // symbol@rel32@lo
292  VK_AMDGPU_REL32_HI, // symbol@rel32@hi
293  VK_AMDGPU_REL64, // symbol@rel64
294 
296  VK_DTPREL
297  };
298 
299 private:
300  /// The symbol reference modifier.
301  const VariantKind Kind;
302 
303  /// Specifies how the variant kind should be printed.
304  const unsigned UseParensForSymbolVariant : 1;
305 
306  // FIXME: Remove this bit.
307  const unsigned HasSubsectionsViaSymbols : 1;
308 
309  /// The symbol being referenced.
310  const MCSymbol *Symbol;
311 
312  explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
313  const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
314 
315 public:
316  /// \name Construction
317  /// @{
318 
319  static const MCSymbolRefExpr *create(const MCSymbol *Symbol, MCContext &Ctx) {
320  return MCSymbolRefExpr::create(Symbol, VK_None, Ctx);
321  }
322 
323  static const MCSymbolRefExpr *create(const MCSymbol *Symbol, VariantKind Kind,
324  MCContext &Ctx, SMLoc Loc = SMLoc());
325  static const MCSymbolRefExpr *create(StringRef Name, VariantKind Kind,
326  MCContext &Ctx);
327 
328  /// @}
329  /// \name Accessors
330  /// @{
331 
332  const MCSymbol &getSymbol() const { return *Symbol; }
333 
334  VariantKind getKind() const { return Kind; }
335 
336  void printVariantKind(raw_ostream &OS) const;
337 
338  bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
339 
340  /// @}
341  /// \name Static Utility Functions
342  /// @{
343 
344  static StringRef getVariantKindName(VariantKind Kind);
345 
346  static VariantKind getVariantKindForName(StringRef Name);
347 
348  /// @}
349 
350  static bool classof(const MCExpr *E) {
351  return E->getKind() == MCExpr::SymbolRef;
352  }
353 };
354 
355 /// Unary assembler expressions.
356 class MCUnaryExpr : public MCExpr {
357 public:
358  enum Opcode {
359  LNot, ///< Logical negation.
360  Minus, ///< Unary minus.
361  Not, ///< Bitwise negation.
362  Plus ///< Unary plus.
363  };
364 
365 private:
366  Opcode Op;
367  const MCExpr *Expr;
368 
369  MCUnaryExpr(Opcode Op, const MCExpr *Expr, SMLoc Loc)
370  : MCExpr(MCExpr::Unary, Loc), Op(Op), Expr(Expr) {}
371 
372 public:
373  /// \name Construction
374  /// @{
375 
376  static const MCUnaryExpr *create(Opcode Op, const MCExpr *Expr,
377  MCContext &Ctx, SMLoc Loc = SMLoc());
378 
379  static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
380  return create(LNot, Expr, Ctx, Loc);
381  }
382 
383  static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
384  return create(Minus, Expr, Ctx, Loc);
385  }
386 
387  static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
388  return create(Not, Expr, Ctx, Loc);
389  }
390 
391  static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc = SMLoc()) {
392  return create(Plus, Expr, Ctx, Loc);
393  }
394 
395  /// @}
396  /// \name Accessors
397  /// @{
398 
399  /// Get the kind of this unary expression.
400  Opcode getOpcode() const { return Op; }
401 
402  /// Get the child of this unary expression.
403  const MCExpr *getSubExpr() const { return Expr; }
404 
405  /// @}
406 
407  static bool classof(const MCExpr *E) {
408  return E->getKind() == MCExpr::Unary;
409  }
410 };
411 
412 /// Binary assembler expressions.
413 class MCBinaryExpr : public MCExpr {
414 public:
415  enum Opcode {
416  Add, ///< Addition.
417  And, ///< Bitwise and.
418  Div, ///< Signed division.
419  EQ, ///< Equality comparison.
420  GT, ///< Signed greater than comparison (result is either 0 or some
421  ///< target-specific non-zero value)
422  GTE, ///< Signed greater than or equal comparison (result is either 0 or
423  ///< some target-specific non-zero value).
424  LAnd, ///< Logical and.
425  LOr, ///< Logical or.
426  LT, ///< Signed less than comparison (result is either 0 or
427  ///< some target-specific non-zero value).
428  LTE, ///< Signed less than or equal comparison (result is either 0 or
429  ///< some target-specific non-zero value).
430  Mod, ///< Signed remainder.
431  Mul, ///< Multiplication.
432  NE, ///< Inequality comparison.
433  Or, ///< Bitwise or.
434  Shl, ///< Shift left.
435  AShr, ///< Arithmetic shift right.
436  LShr, ///< Logical shift right.
437  Sub, ///< Subtraction.
438  Xor ///< Bitwise exclusive or.
439  };
440 
441 private:
442  Opcode Op;
443  const MCExpr *LHS, *RHS;
444 
445  MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS,
446  SMLoc Loc = SMLoc())
447  : MCExpr(MCExpr::Binary, Loc), Op(Op), LHS(LHS), RHS(RHS) {}
448 
449 public:
450  /// \name Construction
451  /// @{
452 
453  static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,
454  const MCExpr *RHS, MCContext &Ctx,
455  SMLoc Loc = SMLoc());
456 
457  static const MCBinaryExpr *createAdd(const MCExpr *LHS, const MCExpr *RHS,
458  MCContext &Ctx) {
459  return create(Add, LHS, RHS, Ctx);
460  }
461 
462  static const MCBinaryExpr *createAnd(const MCExpr *LHS, const MCExpr *RHS,
463  MCContext &Ctx) {
464  return create(And, LHS, RHS, Ctx);
465  }
466 
467  static const MCBinaryExpr *createDiv(const MCExpr *LHS, const MCExpr *RHS,
468  MCContext &Ctx) {
469  return create(Div, LHS, RHS, Ctx);
470  }
471 
472  static const MCBinaryExpr *createEQ(const MCExpr *LHS, const MCExpr *RHS,
473  MCContext &Ctx) {
474  return create(EQ, LHS, RHS, Ctx);
475  }
476 
477  static const MCBinaryExpr *createGT(const MCExpr *LHS, const MCExpr *RHS,
478  MCContext &Ctx) {
479  return create(GT, LHS, RHS, Ctx);
480  }
481 
482  static const MCBinaryExpr *createGTE(const MCExpr *LHS, const MCExpr *RHS,
483  MCContext &Ctx) {
484  return create(GTE, LHS, RHS, Ctx);
485  }
486 
487  static const MCBinaryExpr *createLAnd(const MCExpr *LHS, const MCExpr *RHS,
488  MCContext &Ctx) {
489  return create(LAnd, LHS, RHS, Ctx);
490  }
491 
492  static const MCBinaryExpr *createLOr(const MCExpr *LHS, const MCExpr *RHS,
493  MCContext &Ctx) {
494  return create(LOr, LHS, RHS, Ctx);
495  }
496 
497  static const MCBinaryExpr *createLT(const MCExpr *LHS, const MCExpr *RHS,
498  MCContext &Ctx) {
499  return create(LT, LHS, RHS, Ctx);
500  }
501 
502  static const MCBinaryExpr *createLTE(const MCExpr *LHS, const MCExpr *RHS,
503  MCContext &Ctx) {
504  return create(LTE, LHS, RHS, Ctx);
505  }
506 
507  static const MCBinaryExpr *createMod(const MCExpr *LHS, const MCExpr *RHS,
508  MCContext &Ctx) {
509  return create(Mod, LHS, RHS, Ctx);
510  }
511 
512  static const MCBinaryExpr *createMul(const MCExpr *LHS, const MCExpr *RHS,
513  MCContext &Ctx) {
514  return create(Mul, LHS, RHS, Ctx);
515  }
516 
517  static const MCBinaryExpr *createNE(const MCExpr *LHS, const MCExpr *RHS,
518  MCContext &Ctx) {
519  return create(NE, LHS, RHS, Ctx);
520  }
521 
522  static const MCBinaryExpr *createOr(const MCExpr *LHS, const MCExpr *RHS,
523  MCContext &Ctx) {
524  return create(Or, LHS, RHS, Ctx);
525  }
526 
527  static const MCBinaryExpr *createShl(const MCExpr *LHS, const MCExpr *RHS,
528  MCContext &Ctx) {
529  return create(Shl, LHS, RHS, Ctx);
530  }
531 
532  static const MCBinaryExpr *createAShr(const MCExpr *LHS, const MCExpr *RHS,
533  MCContext &Ctx) {
534  return create(AShr, LHS, RHS, Ctx);
535  }
536 
537  static const MCBinaryExpr *createLShr(const MCExpr *LHS, const MCExpr *RHS,
538  MCContext &Ctx) {
539  return create(LShr, LHS, RHS, Ctx);
540  }
541 
542  static const MCBinaryExpr *createSub(const MCExpr *LHS, const MCExpr *RHS,
543  MCContext &Ctx) {
544  return create(Sub, LHS, RHS, Ctx);
545  }
546 
547  static const MCBinaryExpr *createXor(const MCExpr *LHS, const MCExpr *RHS,
548  MCContext &Ctx) {
549  return create(Xor, LHS, RHS, Ctx);
550  }
551 
552  /// @}
553  /// \name Accessors
554  /// @{
555 
556  /// Get the kind of this binary expression.
557  Opcode getOpcode() const { return Op; }
558 
559  /// Get the left-hand side expression of the binary operator.
560  const MCExpr *getLHS() const { return LHS; }
561 
562  /// Get the right-hand side expression of the binary operator.
563  const MCExpr *getRHS() const { return RHS; }
564 
565  /// @}
566 
567  static bool classof(const MCExpr *E) {
568  return E->getKind() == MCExpr::Binary;
569  }
570 };
571 
572 /// This is an extension point for target-specific MCExpr subclasses to
573 /// implement.
574 ///
575 /// NOTE: All subclasses are required to have trivial destructors because
576 /// MCExprs are bump pointer allocated and not destructed.
577 class MCTargetExpr : public MCExpr {
578  virtual void anchor();
579 
580 protected:
582  virtual ~MCTargetExpr() = default;
583 
584 public:
585  virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
586  virtual bool evaluateAsRelocatableImpl(MCValue &Res,
587  const MCAsmLayout *Layout,
588  const MCFixup *Fixup) const = 0;
589  // allow Target Expressions to be checked for equality
590  virtual bool isEqualTo(const MCExpr *x) const { return false; }
591  // This should be set when assigned expressions are not valid ".set"
592  // expressions, e.g. registers, and must be inlined.
593  virtual bool inlineAssignedExpr() const { return false; }
594  virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
595  virtual MCFragment *findAssociatedFragment() const = 0;
596 
597  virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const = 0;
598 
599  static bool classof(const MCExpr *E) {
600  return E->getKind() == MCExpr::Target;
601  }
602 };
603 
604 } // end namespace llvm
605 
606 #endif // LLVM_MC_MCEXPR_H
static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:379
static const MCBinaryExpr * createGT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:477
static const MCBinaryExpr * createEQ(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:472
Bitwise negation.
Definition: MCExpr.h:361
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:319
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:334
Bitwise and.
Definition: MCExpr.h:417
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Multiplication.
Definition: MCExpr.h:431
Opcode getOpcode() const
Get the kind of this unary expression.
Definition: MCExpr.h:400
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:560
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:462
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:512
Equality comparison.
Definition: MCExpr.h:419
Bitwise or.
Definition: MCExpr.h:433
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:73
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:547
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:467
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:577
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:165
static const MCBinaryExpr * createAShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:532
Context object for machine code objects.
Definition: MCContext.h:62
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:527
virtual bool inlineAssignedExpr() const
Definition: MCExpr.h:593
static const MCBinaryExpr * createLOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:492
Arithmetic shift right.
Definition: MCExpr.h:435
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:542
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:640
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:563
Logical or.
Definition: MCExpr.h:425
Signed remainder.
Definition: MCExpr.h:430
static bool classof(const MCExpr *E)
Definition: MCExpr.h:155
Unary assembler expressions.
Definition: MCExpr.h:356
void dump() const
Definition: MCExpr.cpp:144
Signed division.
Definition: MCExpr.h:418
#define EQ(a, b)
Definition: regexec.c:112
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:457
Unary expressions.
Definition: MCExpr.h:41
Shift left.
Definition: MCExpr.h:434
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:55
int64_t getValue() const
Definition: MCExpr.h:151
static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:391
Streaming machine code generation interface.
Definition: MCStreamer.h:188
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const
Definition: MCExpr.cpp:463
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:41
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:522
Logical negation.
Definition: MCExpr.h:359
Logical and.
Definition: MCExpr.h:424
Binary assembler expressions.
Definition: MCExpr.h:413
bool hasSubsectionsViaSymbols() const
Definition: MCExpr.h:338
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:537
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:383
PowerPC TLS Dynamic Call Fixup
static bool classof(const MCExpr *E)
Definition: MCExpr.h:567
const MCSymbol & getSymbol() const
Definition: MCExpr.h:332
ExprKind getKind() const
Definition: MCExpr.h:72
static const MCBinaryExpr * createLT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:497
static bool classof(const MCExpr *E)
Definition: MCExpr.h:599
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const
Definition: MCExpr.cpp:667
Inequality comparison.
Definition: MCExpr.h:432
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:860
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:487
Logical shift right.
Definition: MCExpr.h:436
static const MCBinaryExpr * createNE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:517
static const MCBinaryExpr * createLTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:502
static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.h:387
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:507
References to labels and assigned expressions.
Definition: MCExpr.h:40
Unary minus.
Definition: MCExpr.h:360
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:648
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:2038
virtual bool isEqualTo(const MCExpr *x) const
Definition: MCExpr.h:590
static bool classof(const MCExpr *E)
Definition: MCExpr.h:407
Opcode getOpcode() const
Get the kind of this binary expression.
Definition: MCExpr.h:557
const MCExpr * getSubExpr() const
Get the child of this unary expression.
Definition: MCExpr.h:403
LLVM Value Representation.
Definition: Value.h:72
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:437
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:350
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:482