LLVM  4.0.0
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/Casting.h"
15 #include "llvm/Support/DataTypes.h"
16 
17 namespace llvm {
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;
31 
32 /// \brief Base class for the full range of assembler expressions which are
33 /// needed for parsing.
34 class MCExpr {
35 public:
36  enum ExprKind {
37  Binary, ///< Binary expressions.
38  Constant, ///< Constant expressions.
39  SymbolRef, ///< References to labels and assigned expressions.
40  Unary, ///< Unary expressions.
41  Target ///< Target specific expression.
42  };
43 
44 private:
45  ExprKind Kind;
46 
47  MCExpr(const MCExpr&) = delete;
48  void operator=(const MCExpr&) = delete;
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) : Kind(Kind) {}
60 
62  const MCAsmLayout *Layout,
63  const MCFixup *Fixup,
64  const SectionAddrMap *Addrs, bool InSet) const;
65 
66 public:
67  /// \name Accessors
68  /// @{
69 
70  ExprKind getKind() const { return Kind; }
71 
72  /// @}
73  /// \name Utility Methods
74  /// @{
75 
76  void print(raw_ostream &OS, const MCAsmInfo *MAI,
77  bool InParens = false) const;
78  void dump() const;
79 
80  /// @}
81  /// \name Expression Evaluation
82  /// @{
83 
84  /// \brief Try to evaluate the expression to an absolute value.
85  ///
86  /// \param Res - The absolute value, if evaluation succeeds.
87  /// \param Layout - The assembler layout object to use for evaluating symbol
88  /// values. If not given, then only non-symbolic expressions will be
89  /// evaluated.
90  /// \return - True on success.
91  bool evaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout,
92  const SectionAddrMap &Addrs) const;
93  bool evaluateAsAbsolute(int64_t &Res) 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  /// \brief 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  /// \brief 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  /// \brief 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 //// \brief Represent a constant integer expression.
131 class MCConstantExpr : public MCExpr {
132  int64_t Value;
133 
134  explicit MCConstantExpr(int64_t Value)
135  : MCExpr(MCExpr::Constant), Value(Value) {}
136 
137 public:
138  /// \name Construction
139  /// @{
140 
141  static const MCConstantExpr *create(int64_t Value, MCContext &Ctx);
142 
143  /// @}
144  /// \name Accessors
145  /// @{
146 
147  int64_t getValue() const { return Value; }
148 
149  /// @}
150 
151  static bool classof(const MCExpr *E) {
152  return E->getKind() == MCExpr::Constant;
153  }
154 };
155 
156 /// \brief Represent a reference to a symbol from inside an expression.
157 ///
158 /// A symbol reference in an expression may be a use of a label, a use of an
159 /// assembler variable (defined constant), or constitute an implicit definition
160 /// of the symbol as external.
161 class MCSymbolRefExpr : public MCExpr {
162 public:
163  enum VariantKind : uint16_t {
166 
181  VK_TLSCALL, // symbol(tlscall)
182  VK_TLSDESC, // symbol(tlsdesc)
183  VK_TLVP, // Mach-O thread local variable relocations
191  VK_SIZE, // symbol@SIZE
192  VK_WEAKREF, // The link between the symbols in .weakref foo, bar
193 
199  VK_ARM_SBREL, // symbol(sbrel)
200  VK_ARM_TLSLDO, // symbol(tlsldo)
202 
203  VK_PPC_LO, // symbol@l
204  VK_PPC_HI, // symbol@h
205  VK_PPC_HA, // symbol@ha
206  VK_PPC_HIGHER, // symbol@higher
207  VK_PPC_HIGHERA, // symbol@highera
208  VK_PPC_HIGHEST, // symbol@highest
209  VK_PPC_HIGHESTA, // symbol@highesta
210  VK_PPC_GOT_LO, // symbol@got@l
211  VK_PPC_GOT_HI, // symbol@got@h
212  VK_PPC_GOT_HA, // symbol@got@ha
213  VK_PPC_TOCBASE, // symbol@tocbase
214  VK_PPC_TOC, // symbol@toc
215  VK_PPC_TOC_LO, // symbol@toc@l
216  VK_PPC_TOC_HI, // symbol@toc@h
217  VK_PPC_TOC_HA, // symbol@toc@ha
218  VK_PPC_DTPMOD, // symbol@dtpmod
219  VK_PPC_TPREL_LO, // symbol@tprel@l
220  VK_PPC_TPREL_HI, // symbol@tprel@h
221  VK_PPC_TPREL_HA, // symbol@tprel@ha
222  VK_PPC_TPREL_HIGHER, // symbol@tprel@higher
223  VK_PPC_TPREL_HIGHERA, // symbol@tprel@highera
224  VK_PPC_TPREL_HIGHEST, // symbol@tprel@highest
225  VK_PPC_TPREL_HIGHESTA, // symbol@tprel@highesta
226  VK_PPC_DTPREL_LO, // symbol@dtprel@l
227  VK_PPC_DTPREL_HI, // symbol@dtprel@h
228  VK_PPC_DTPREL_HA, // symbol@dtprel@ha
229  VK_PPC_DTPREL_HIGHER, // symbol@dtprel@higher
230  VK_PPC_DTPREL_HIGHERA, // symbol@dtprel@highera
231  VK_PPC_DTPREL_HIGHEST, // symbol@dtprel@highest
232  VK_PPC_DTPREL_HIGHESTA,// symbol@dtprel@highesta
233  VK_PPC_GOT_TPREL, // symbol@got@tprel
234  VK_PPC_GOT_TPREL_LO, // symbol@got@tprel@l
235  VK_PPC_GOT_TPREL_HI, // symbol@got@tprel@h
236  VK_PPC_GOT_TPREL_HA, // symbol@got@tprel@ha
237  VK_PPC_GOT_DTPREL, // symbol@got@dtprel
238  VK_PPC_GOT_DTPREL_LO, // symbol@got@dtprel@l
239  VK_PPC_GOT_DTPREL_HI, // symbol@got@dtprel@h
240  VK_PPC_GOT_DTPREL_HA, // symbol@got@dtprel@ha
241  VK_PPC_TLS, // symbol@tls
242  VK_PPC_GOT_TLSGD, // symbol@got@tlsgd
243  VK_PPC_GOT_TLSGD_LO, // symbol@got@tlsgd@l
244  VK_PPC_GOT_TLSGD_HI, // symbol@got@tlsgd@h
245  VK_PPC_GOT_TLSGD_HA, // symbol@got@tlsgd@ha
246  VK_PPC_TLSGD, // symbol@tlsgd
247  VK_PPC_GOT_TLSLD, // symbol@got@tlsld
248  VK_PPC_GOT_TLSLD_LO, // symbol@got@tlsld@l
249  VK_PPC_GOT_TLSLD_HI, // symbol@got@tlsld@h
250  VK_PPC_GOT_TLSLD_HA, // symbol@got@tlsld@ha
251  VK_PPC_TLSLD, // symbol@tlsld
252  VK_PPC_LOCAL, // symbol@local
253 
254  VK_COFF_IMGREL32, // symbol@imgrel (image-relative)
255 
266 
267  VK_WebAssembly_FUNCTION, // Function table index, rather than virtual addr
268 
269  VK_AMDGPU_GOTPCREL32_LO, // symbol@gotpcrel32@lo
270  VK_AMDGPU_GOTPCREL32_HI, // symbol@gotpcrel32@hi
271  VK_AMDGPU_REL32_LO, // symbol@rel32@lo
272  VK_AMDGPU_REL32_HI, // symbol@rel32@hi
273 
276  };
277 
278 private:
279  /// The symbol reference modifier.
280  const VariantKind Kind;
281 
282  /// Specifies how the variant kind should be printed.
283  const unsigned UseParensForSymbolVariant : 1;
284 
285  // FIXME: Remove this bit.
286  const unsigned HasSubsectionsViaSymbols : 1;
287 
288  /// The symbol being referenced.
289  const MCSymbol *Symbol;
290 
291  explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
292  const MCAsmInfo *MAI);
293 
294 public:
295  /// \name Construction
296  /// @{
297 
298  static const MCSymbolRefExpr *create(const MCSymbol *Symbol, MCContext &Ctx) {
299  return MCSymbolRefExpr::create(Symbol, VK_None, Ctx);
300  }
301 
302  static const MCSymbolRefExpr *create(const MCSymbol *Symbol, VariantKind Kind,
303  MCContext &Ctx);
304  static const MCSymbolRefExpr *create(StringRef Name, VariantKind Kind,
305  MCContext &Ctx);
306 
307  /// @}
308  /// \name Accessors
309  /// @{
310 
311  const MCSymbol &getSymbol() const { return *Symbol; }
312 
313  VariantKind getKind() const { return Kind; }
314 
315  void printVariantKind(raw_ostream &OS) const;
316 
317  bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
318 
319  /// @}
320  /// \name Static Utility Functions
321  /// @{
322 
324 
326 
327  /// @}
328 
329  static bool classof(const MCExpr *E) {
330  return E->getKind() == MCExpr::SymbolRef;
331  }
332 };
333 
334 /// \brief Unary assembler expressions.
335 class MCUnaryExpr : public MCExpr {
336 public:
337  enum Opcode {
338  LNot, ///< Logical negation.
339  Minus, ///< Unary minus.
340  Not, ///< Bitwise negation.
341  Plus ///< Unary plus.
342  };
343 
344 private:
345  Opcode Op;
346  const MCExpr *Expr;
347 
348  MCUnaryExpr(Opcode Op, const MCExpr *Expr)
349  : MCExpr(MCExpr::Unary), Op(Op), Expr(Expr) {}
350 
351 public:
352  /// \name Construction
353  /// @{
354 
355  static const MCUnaryExpr *create(Opcode Op, const MCExpr *Expr,
356  MCContext &Ctx);
357  static const MCUnaryExpr *createLNot(const MCExpr *Expr, MCContext &Ctx) {
358  return create(LNot, Expr, Ctx);
359  }
360  static const MCUnaryExpr *createMinus(const MCExpr *Expr, MCContext &Ctx) {
361  return create(Minus, Expr, Ctx);
362  }
363  static const MCUnaryExpr *createNot(const MCExpr *Expr, MCContext &Ctx) {
364  return create(Not, Expr, Ctx);
365  }
366  static const MCUnaryExpr *createPlus(const MCExpr *Expr, MCContext &Ctx) {
367  return create(Plus, Expr, Ctx);
368  }
369 
370  /// @}
371  /// \name Accessors
372  /// @{
373 
374  /// \brief Get the kind of this unary expression.
375  Opcode getOpcode() const { return Op; }
376 
377  /// \brief Get the child of this unary expression.
378  const MCExpr *getSubExpr() const { return Expr; }
379 
380  /// @}
381 
382  static bool classof(const MCExpr *E) {
383  return E->getKind() == MCExpr::Unary;
384  }
385 };
386 
387 /// \brief Binary assembler expressions.
388 class MCBinaryExpr : public MCExpr {
389 public:
390  enum Opcode {
391  Add, ///< Addition.
392  And, ///< Bitwise and.
393  Div, ///< Signed division.
394  EQ, ///< Equality comparison.
395  GT, ///< Signed greater than comparison (result is either 0 or some
396  ///< target-specific non-zero value)
397  GTE, ///< Signed greater than or equal comparison (result is either 0 or
398  ///< some target-specific non-zero value).
399  LAnd, ///< Logical and.
400  LOr, ///< Logical or.
401  LT, ///< Signed less than comparison (result is either 0 or
402  ///< some target-specific non-zero value).
403  LTE, ///< Signed less than or equal comparison (result is either 0 or
404  ///< some target-specific non-zero value).
405  Mod, ///< Signed remainder.
406  Mul, ///< Multiplication.
407  NE, ///< Inequality comparison.
408  Or, ///< Bitwise or.
409  Shl, ///< Shift left.
410  AShr, ///< Arithmetic shift right.
411  LShr, ///< Logical shift right.
412  Sub, ///< Subtraction.
413  Xor ///< Bitwise exclusive or.
414  };
415 
416 private:
417  Opcode Op;
418  const MCExpr *LHS, *RHS;
419 
420  MCBinaryExpr(Opcode Op, const MCExpr *LHS, const MCExpr *RHS)
421  : MCExpr(MCExpr::Binary), Op(Op), LHS(LHS), RHS(RHS) {}
422 
423 public:
424  /// \name Construction
425  /// @{
426 
427  static const MCBinaryExpr *create(Opcode Op, const MCExpr *LHS,
428  const MCExpr *RHS, MCContext &Ctx);
429  static const MCBinaryExpr *createAdd(const MCExpr *LHS, const MCExpr *RHS,
430  MCContext &Ctx) {
431  return create(Add, LHS, RHS, Ctx);
432  }
433  static const MCBinaryExpr *createAnd(const MCExpr *LHS, const MCExpr *RHS,
434  MCContext &Ctx) {
435  return create(And, LHS, RHS, Ctx);
436  }
437  static const MCBinaryExpr *createDiv(const MCExpr *LHS, const MCExpr *RHS,
438  MCContext &Ctx) {
439  return create(Div, LHS, RHS, Ctx);
440  }
441  static const MCBinaryExpr *createEQ(const MCExpr *LHS, const MCExpr *RHS,
442  MCContext &Ctx) {
443  return create(EQ, LHS, RHS, Ctx);
444  }
445  static const MCBinaryExpr *createGT(const MCExpr *LHS, const MCExpr *RHS,
446  MCContext &Ctx) {
447  return create(GT, LHS, RHS, Ctx);
448  }
449  static const MCBinaryExpr *createGTE(const MCExpr *LHS, const MCExpr *RHS,
450  MCContext &Ctx) {
451  return create(GTE, LHS, RHS, Ctx);
452  }
453  static const MCBinaryExpr *createLAnd(const MCExpr *LHS, const MCExpr *RHS,
454  MCContext &Ctx) {
455  return create(LAnd, LHS, RHS, Ctx);
456  }
457  static const MCBinaryExpr *createLOr(const MCExpr *LHS, const MCExpr *RHS,
458  MCContext &Ctx) {
459  return create(LOr, LHS, RHS, Ctx);
460  }
461  static const MCBinaryExpr *createLT(const MCExpr *LHS, const MCExpr *RHS,
462  MCContext &Ctx) {
463  return create(LT, LHS, RHS, Ctx);
464  }
465  static const MCBinaryExpr *createLTE(const MCExpr *LHS, const MCExpr *RHS,
466  MCContext &Ctx) {
467  return create(LTE, LHS, RHS, Ctx);
468  }
469  static const MCBinaryExpr *createMod(const MCExpr *LHS, const MCExpr *RHS,
470  MCContext &Ctx) {
471  return create(Mod, LHS, RHS, Ctx);
472  }
473  static const MCBinaryExpr *createMul(const MCExpr *LHS, const MCExpr *RHS,
474  MCContext &Ctx) {
475  return create(Mul, LHS, RHS, Ctx);
476  }
477  static const MCBinaryExpr *createNE(const MCExpr *LHS, const MCExpr *RHS,
478  MCContext &Ctx) {
479  return create(NE, LHS, RHS, Ctx);
480  }
481  static const MCBinaryExpr *createOr(const MCExpr *LHS, const MCExpr *RHS,
482  MCContext &Ctx) {
483  return create(Or, LHS, RHS, Ctx);
484  }
485  static const MCBinaryExpr *createShl(const MCExpr *LHS, const MCExpr *RHS,
486  MCContext &Ctx) {
487  return create(Shl, LHS, RHS, Ctx);
488  }
489  static const MCBinaryExpr *createAShr(const MCExpr *LHS, const MCExpr *RHS,
490  MCContext &Ctx) {
491  return create(AShr, LHS, RHS, Ctx);
492  }
493  static const MCBinaryExpr *createLShr(const MCExpr *LHS, const MCExpr *RHS,
494  MCContext &Ctx) {
495  return create(LShr, LHS, RHS, Ctx);
496  }
497  static const MCBinaryExpr *createSub(const MCExpr *LHS, const MCExpr *RHS,
498  MCContext &Ctx) {
499  return create(Sub, LHS, RHS, Ctx);
500  }
501  static const MCBinaryExpr *createXor(const MCExpr *LHS, const MCExpr *RHS,
502  MCContext &Ctx) {
503  return create(Xor, LHS, RHS, Ctx);
504  }
505 
506  /// @}
507  /// \name Accessors
508  /// @{
509 
510  /// \brief Get the kind of this binary expression.
511  Opcode getOpcode() const { return Op; }
512 
513  /// \brief Get the left-hand side expression of the binary operator.
514  const MCExpr *getLHS() const { return LHS; }
515 
516  /// \brief Get the right-hand side expression of the binary operator.
517  const MCExpr *getRHS() const { return RHS; }
518 
519  /// @}
520 
521  static bool classof(const MCExpr *E) {
522  return E->getKind() == MCExpr::Binary;
523  }
524 };
525 
526 /// \brief This is an extension point for target-specific MCExpr subclasses to
527 /// implement.
528 ///
529 /// NOTE: All subclasses are required to have trivial destructors because
530 /// MCExprs are bump pointer allocated and not destructed.
531 class MCTargetExpr : public MCExpr {
532  virtual void anchor();
533 protected:
535  virtual ~MCTargetExpr() {}
536 public:
537  virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
538  virtual bool evaluateAsRelocatableImpl(MCValue &Res,
539  const MCAsmLayout *Layout,
540  const MCFixup *Fixup) const = 0;
541  virtual void visitUsedExpr(MCStreamer& Streamer) const = 0;
542  virtual MCFragment *findAssociatedFragment() const = 0;
543 
544  virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const = 0;
545 
546  static bool classof(const MCExpr *E) {
547  return E->getKind() == MCExpr::Target;
548  }
549 };
550 
551 } // end namespace llvm
552 
553 #endif
bool evaluateKnownAbsolute(int64_t &Res, const MCAsmLayout &Layout) const
Definition: MCExpr.cpp:418
static const MCBinaryExpr * createGT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:445
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:765
Signed less than comparison (result is either 0 or some target-specific non-zero value).
Definition: MCExpr.h:401
static const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx)
Definition: MCExpr.cpp:144
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx)
Definition: MCExpr.h:360
static const MCBinaryExpr * createEQ(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:441
Bitwise negation.
Definition: MCExpr.h:340
const MCSymbol & getSymbol() const
Definition: MCExpr.h:311
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:298
Signed less than or equal comparison (result is either 0 or some target-specific non-zero value)...
Definition: MCExpr.h:403
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:39
Bitwise and.
Definition: MCExpr.h:392
Multiplication.
Definition: MCExpr.h:406
static VariantKind getVariantKindForName(StringRef Name)
Definition: MCExpr.cpp:287
ExprKind getKind() const
Definition: MCExpr.h:70
Unary plus.
Definition: MCExpr.h:341
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:433
void dump() const
Definition: MCExpr.cpp:132
static const MCBinaryExpr * createMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:473
Equality comparison.
Definition: MCExpr.h:394
void printVariantKind(raw_ostream &OS) const
Definition: MCExpr.cpp:386
Bitwise or.
Definition: MCExpr.h:408
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:66
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.cpp:139
static const MCBinaryExpr * createXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:501
virtual void visitUsedExpr(MCStreamer &Streamer) const =0
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:437
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:531
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:161
virtual MCFragment * findAssociatedFragment() const =0
static const MCBinaryExpr * createAShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:489
Context object for machine code objects.
Definition: MCContext.h:51
static const MCBinaryExpr * createShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:485
static const MCBinaryExpr * createLOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:457
Arithmetic shift right.
Definition: MCExpr.h:410
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:497
Logical or.
Definition: MCExpr.h:400
Signed remainder.
Definition: MCExpr.h:405
static bool classof(const MCExpr *E)
Definition: MCExpr.h:151
Unary assembler expressions.
Definition: MCExpr.h:335
Signed division.
Definition: MCExpr.h:393
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:429
static const MCUnaryExpr * createLNot(const MCExpr *Expr, MCContext &Ctx)
Definition: MCExpr.h:357
Unary expressions.
Definition: MCExpr.h:40
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
Shift left.
Definition: MCExpr.h:409
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:57
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:514
Streaming machine code generation interface.
Definition: MCStreamer.h:161
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, const MCFixup *Fixup, const SectionAddrMap *Addrs, bool InSet) const
Definition: MCExpr.cpp:608
int64_t getValue() const
Definition: MCExpr.h:147
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:589
static const MCBinaryExpr * createOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:481
Logical negation.
Definition: MCExpr.h:338
DenseMap< const MCSection *, uint64_t > SectionAddrMap
Definition: MCExpr.h:29
Logical and.
Definition: MCExpr.h:399
virtual bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const =0
Binary assembler expressions.
Definition: MCExpr.h:388
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:493
virtual void fixELFSymbolsInTLSFixups(MCAssembler &) const =0
static bool classof(const MCExpr *E)
Definition: MCExpr.h:521
static const MCBinaryExpr * createLT(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:461
static bool classof(const MCExpr *E)
Definition: MCExpr.h:546
bool hasSubsectionsViaSymbols() const
Definition: MCExpr.h:317
Inequality comparison.
Definition: MCExpr.h:407
Signed greater than comparison (result is either 0 or some target-specific non-zero value) ...
Definition: MCExpr.h:395
static const MCUnaryExpr * createPlus(const MCExpr *Expr, MCContext &Ctx)
Definition: MCExpr.h:366
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:581
Signed greater than or equal comparison (result is either 0 or some target-specific non-zero value)...
Definition: MCExpr.h:397
Target - Wrapper for Target specific information.
Bitwise exclusive or.
Definition: MCExpr.h:413
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:517
static const MCBinaryExpr * createLAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:453
Logical shift right.
Definition: MCExpr.h:411
static const MCBinaryExpr * createNE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:477
const MCExpr * getSubExpr() const
Get the child of this unary expression.
Definition: MCExpr.h:378
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const =0
MCExpr(ExprKind Kind)
Definition: MCExpr.h:59
static const MCBinaryExpr * createLTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:465
Opcode getOpcode() const
Get the kind of this binary expression.
Definition: MCExpr.h:511
static const MCBinaryExpr * createMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:469
References to labels and assigned expressions.
Definition: MCExpr.h:39
Unary minus.
Definition: MCExpr.h:339
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1726
static bool classof(const MCExpr *E)
Definition: MCExpr.h:382
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:33
VariantKind getKind() const
Definition: MCExpr.h:313
virtual ~MCTargetExpr()
Definition: MCExpr.h:535
LLVM Value Representation.
Definition: Value.h:71
Constant expressions.
Definition: MCExpr.h:38
Binary expressions.
Definition: MCExpr.h:37
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
Subtraction.
Definition: MCExpr.h:412
static const MCUnaryExpr * createNot(const MCExpr *Expr, MCContext &Ctx)
Definition: MCExpr.h:363
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
Target specific expression.
Definition: MCExpr.h:41
static bool classof(const MCExpr *E)
Definition: MCExpr.h:329
static const MCBinaryExpr * createGTE(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:449
static StringRef getVariantKindName(VariantKind Kind)
Definition: MCExpr.cpp:175
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:149
Opcode getOpcode() const
Get the kind of this unary expression.
Definition: MCExpr.h:375