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