1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- MCFragment.h - Fragment type hierarchy -------------------*- C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_MC_MCFRAGMENT_H
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_MC_MCFRAGMENT_H
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/ArrayRef.h"
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/SmallString.h"
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/SmallVector.h"
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h"
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/ilist_node.h"
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCFixup.h"
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCInst.h"
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/SMLoc.h"
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstdint>
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <utility>
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSection;
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSubtargetInfo;
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSymbol;
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCFragment : public ilist_node_with_parent<MCFragment, MCSection> {
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class MCAsmLayout;
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum FragmentType : uint8_t {
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Align,
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Data,
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_CompactEncodedInst,
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Fill,
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Relaxable,
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Org,
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Dwarf,
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_DwarfFrame,
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_LEB,
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_SafeSEH,
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_CVInlineLines,
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_CVDefRange,
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    FT_Dummy
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  FragmentType Kind;
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool HasInstructions;
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Should this fragment be aligned to the end of a bundle?
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool AlignToBundleEnd;
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t BundlePadding;
61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// LayoutOrder - The layout order of this fragment.
63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned LayoutOrder;
64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The data for the section this fragment is in.
66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCSection *Parent;
67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Atom - The atom this fragment is in, as represented by it's defining
69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// symbol.
70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *Atom;
71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Assembler Backend Data
73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // FIXME: This could all be kept private to the assembler implementation.
76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Offset - The offset of this fragment in its section. This is ~0 until
78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// initialized.
79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t Offset;
80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCFragment(FragmentType Kind, bool HasInstructions,
85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot             uint8_t BundlePadding, MCSection *Parent = nullptr);
86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ~MCFragment();
88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCFragment() = delete;
91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCFragment(const MCFragment &) = delete;
92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCFragment &operator=(const MCFragment &) = delete;
93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Destroys the current fragment.
95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This must be used instead of delete as MCFragment is non-virtual.
97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method will dispatch to the appropriate subclass.
98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void destroy();
99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  FragmentType getKind() const { return Kind; }
101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCSection *getParent() const { return Parent; }
103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setParent(MCSection *Value) { Parent = Value; }
104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *getAtom() const { return Atom; }
106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setAtom(const MCSymbol *Value) { Atom = Value; }
107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getLayoutOrder() const { return LayoutOrder; }
109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Does this fragment have instructions emitted into it? By default
112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// this is false, but specific fragment types may set it to true.
113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasInstructions() const { return HasInstructions; }
114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Should this fragment be placed at the end of an aligned bundle?
116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool alignToBundleEnd() const { return AlignToBundleEnd; }
117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; }
118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Get the padding size that must be inserted before this fragment.
120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Used for bundling. By default, no padding is inserted.
121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Note that padding size is restricted to 8 bits. This is an optimization
122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to reduce the amount of space used for each fragment. In practice, larger
123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// padding should never be required.
124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t getBundlePadding() const { return BundlePadding; }
125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Set the padding size for this fragment. By default it's a no-op,
127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and only some fragments have a meaningful implementation.
128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setBundlePadding(uint8_t N) { BundlePadding = N; }
129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if given frgment has FT_Dummy type.
131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isDummy() const { return Kind == FT_Dummy; }
132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void dump() const;
134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCDummyFragment : public MCFragment {
137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  explicit MCDummyFragment(MCSection *Sec)
139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_Dummy, false, 0, Sec) {}
140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) { return F->getKind() == FT_Dummy; }
142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Interface implemented by fragments that contain encoded instructions and/or
145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// data.
146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCEncodedFragment : public MCFragment {
148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCEncodedFragment(MCFragment::FragmentType FType, bool HasInstructions,
150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                    MCSection *Sec)
151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FType, HasInstructions, 0, Sec) {}
152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCFragment::FragmentType Kind = F->getKind();
156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    switch (Kind) {
157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    default:
158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case MCFragment::FT_Relaxable:
160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case MCFragment::FT_CompactEncodedInst:
161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case MCFragment::FT_Data:
162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return true;
163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Interface implemented by fragments that contain encoded instructions and/or
168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// data.
169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate<unsigned ContentsSize>
171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCEncodedFragmentWithContents : public MCEncodedFragment {
172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVector<char, ContentsSize> Contents;
173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCEncodedFragmentWithContents(MCFragment::FragmentType FType,
176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                bool HasInstructions,
177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                MCSection *Sec)
178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCEncodedFragment(FType, HasInstructions, Sec) {}
179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVectorImpl<char> &getContents() { return Contents; }
182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallVectorImpl<char> &getContents() const { return Contents; }
183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Interface implemented by fragments that contain encoded instructions and/or
186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// data and also have fixups registered.
187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robottemplate<unsigned ContentsSize, unsigned FixupsSize>
189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCEncodedFragmentWithFixups :
190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  public MCEncodedFragmentWithContents<ContentsSize> {
191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Fixups - The list of fixups in this fragment.
193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVector<MCFixup, FixupsSize> Fixups;
194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCEncodedFragmentWithFixups(MCFragment::FragmentType FType,
197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              bool HasInstructions,
198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              MCSection *Sec)
199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCEncodedFragmentWithContents<ContentsSize>(FType, HasInstructions,
200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                    Sec) {}
201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using const_fixup_iterator = SmallVectorImpl<MCFixup>::const_iterator;
204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using fixup_iterator = SmallVectorImpl<MCFixup>::iterator;
205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVectorImpl<MCFixup> &getFixups() { return Fixups; }
207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; }
208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  fixup_iterator fixup_begin() { return Fixups.begin(); }
210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  fixup_iterator fixup_end() { return Fixups.end(); }
213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const_fixup_iterator fixup_end() const { return Fixups.end(); }
214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCFragment::FragmentType Kind = F->getKind();
217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Kind == MCFragment::FT_Relaxable || Kind == MCFragment::FT_Data ||
218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           Kind == MCFragment::FT_CVDefRange;
219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Fragment for data and encoded instructions.
223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCDataFragment(MCSection *Sec = nullptr)
227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCEncodedFragmentWithFixups<32, 4>(FT_Data, false, Sec) {}
228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setHasInstructions(bool V) { HasInstructions = V; }
230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_Data;
233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This is a compact (memory-size-wise) fragment for holding an encoded
237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// instruction (non-relaxable) that has no fixups registered. When applicable,
238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// it can be used instead of MCDataFragment and lead to lower memory
239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// consumption.
240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCCompactEncodedInstFragment : public MCEncodedFragmentWithContents<4> {
242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCCompactEncodedInstFragment(MCSection *Sec = nullptr)
244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCEncodedFragmentWithContents(FT_CompactEncodedInst, true, Sec) {
245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_CompactEncodedInst;
249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// A relaxable fragment holds on to its MCInst, since it may need to be
253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// relaxed during the assembler layout and relaxation stage.
254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCRelaxableFragment : public MCEncodedFragmentWithFixups<8, 1> {
256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Inst - The instruction this is a fragment for.
258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCInst Inst;
259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// STI - The MCSubtargetInfo in effect when the instruction was encoded.
261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSubtargetInfo &STI;
262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI,
265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                      MCSection *Sec = nullptr)
266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCEncodedFragmentWithFixups(FT_Relaxable, true, Sec),
267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        Inst(Inst), STI(STI) {}
268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCInst &getInst() const { return Inst; }
270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setInst(const MCInst &Value) { Inst = Value; }
271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSubtargetInfo &getSubtargetInfo() { return STI; }
273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_Relaxable;
276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCAlignFragment : public MCFragment {
280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Alignment - The alignment to ensure, in bytes.
281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned Alignment;
282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// of using the provided value. The exact interpretation of this flag is
285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target dependent.
286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool EmitNops : 1;
287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Value - Value to use for filling padding bytes.
289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int64_t Value;
290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ValueSize - The size of the integer (in bytes) of \p Value.
292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned ValueSize;
293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// cannot be satisfied in this width then this fragment is ignored.
296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxBytesToEmit;
297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCAlignFragment(unsigned Alignment, int64_t Value, unsigned ValueSize,
300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                  unsigned MaxBytesToEmit, MCSection *Sec = nullptr)
301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_Align, false, 0, Sec), Alignment(Alignment),
302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        EmitNops(false), Value(Value),
303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {}
304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getAlignment() const { return Alignment; }
309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int64_t getValue() const { return Value; }
311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getValueSize() const { return ValueSize; }
313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasEmitNops() const { return EmitNops; }
317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setEmitNops(bool Value) { EmitNops = Value; }
318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_Align;
323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCFillFragment : public MCFragment {
327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Value to use for filling bytes.
328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t Value;
329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The number of bytes to insert.
331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t Size;
332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCFillFragment(uint8_t Value, uint64_t Size, MCSection *Sec = nullptr)
335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_Fill, false, 0, Sec), Value(Value), Size(Size) {}
336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t getValue() const { return Value; }
338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getSize() const { return Size; }
339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_Fill;
342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCOrgFragment : public MCFragment {
346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Offset - The offset this fragment should start at.
347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr *Offset;
348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Value - Value to use for filling bytes.
350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int8_t Value;
351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Loc - Source location of the directive that this fragment was created for.
353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SMLoc Loc;
354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc,
357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                MCSection *Sec = nullptr)
358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_Org, false, 0, Sec), Offset(&Offset), Value(Value), Loc(Loc) {}
359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr &getOffset() const { return *Offset; }
364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t getValue() const { return Value; }
366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SMLoc getLoc() const { return Loc; }
368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_Org;
373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCLEBFragment : public MCFragment {
377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Value - The value this fragment should contain.
378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr *Value;
379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// IsSigned - True if this is a sleb128, false if uleb128.
381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool IsSigned;
382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> Contents;
384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSection *Sec = nullptr)
387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_LEB, false, 0, Sec), Value(&Value_), IsSigned(IsSigned_) {
388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Contents.push_back(0);
389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr &getValue() const { return *Value; }
395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isSigned() const { return IsSigned; }
397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> &getContents() { return Contents; }
399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallString<8> &getContents() const { return Contents; }
400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_LEB;
405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCDwarfLineAddrFragment : public MCFragment {
409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// LineDelta - the value of the difference between the two line numbers
410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// between two .loc dwarf directives.
411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int64_t LineDelta;
412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AddrDelta - The expression for the difference of the two symbols that
414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// make up the address delta between two .loc dwarf directives.
415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr *AddrDelta;
416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> Contents;
418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta,
421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          MCSection *Sec = nullptr)
422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_Dwarf, false, 0, Sec), LineDelta(LineDelta),
423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        AddrDelta(&AddrDelta) {
424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Contents.push_back(0);
425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int64_t getLineDelta() const { return LineDelta; }
431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr &getAddrDelta() const { return *AddrDelta; }
433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> &getContents() { return Contents; }
435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallString<8> &getContents() const { return Contents; }
436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_Dwarf;
441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCDwarfCallFrameFragment : public MCFragment {
445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AddrDelta - The expression for the difference of the two symbols that
446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// make up the address delta between two .cfi_* dwarf directives.
447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr *AddrDelta;
448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> Contents;
450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCDwarfCallFrameFragment(const MCExpr &AddrDelta, MCSection *Sec = nullptr)
453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_DwarfFrame, false, 0, Sec), AddrDelta(&AddrDelta) {
454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Contents.push_back(0);
455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr &getAddrDelta() const { return *AddrDelta; }
461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> &getContents() { return Contents; }
463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallString<8> &getContents() const { return Contents; }
464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_DwarfFrame;
469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSafeSEHFragment : public MCFragment {
473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *Sym;
474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCSafeSEHFragment(const MCSymbol *Sym, MCSection *Sec = nullptr)
477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_SafeSEH, false, 0, Sec), Sym(Sym) {}
478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *getSymbol() { return Sym; }
483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *getSymbol() const { return Sym; }
484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_SafeSEH;
489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Fragment representing the binary annotations produced by the
493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// .cv_inline_linetable directive.
494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCCVInlineLineTableFragment : public MCFragment {
495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned SiteFuncId;
496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned StartFileId;
497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned StartLineNum;
498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *FnStartSym;
499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *FnEndSym;
500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> Contents;
501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// CodeViewContext has the real knowledge about this format, so let it access
503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// our members.
504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class CodeViewContext;
505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              unsigned StartLineNum, const MCSymbol *FnStartSym,
509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const MCSymbol *FnEndSym,
510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              MCSection *Sec = nullptr)
511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCFragment(FT_CVInlineLines, false, 0, Sec), SiteFuncId(SiteFuncId),
512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        StartFileId(StartFileId), StartLineNum(StartLineNum),
513c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
514c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
515c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
516c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
517c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
518c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *getFnStartSym() const { return FnStartSym; }
519c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCSymbol *getFnEndSym() const { return FnEndSym; }
520c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
521c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<8> &getContents() { return Contents; }
522c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallString<8> &getContents() const { return Contents; }
523c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
524c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
525c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
526c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
527c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_CVInlineLines;
528c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
529c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
530c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
531c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Fragment representing the .cv_def_range directive.
532c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
533c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVector<std::pair<const MCSymbol *, const MCSymbol *>, 2> Ranges;
534c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallString<32> FixedSizePortion;
535c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
536c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// CodeViewContext has the real knowledge about this format, so let it access
537c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// our members.
538c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class CodeViewContext;
539c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
540c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
541c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCCVDefRangeFragment(
542c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
543c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      StringRef FixedSizePortion, MCSection *Sec = nullptr)
544c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false, Sec),
545c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        Ranges(Ranges.begin(), Ranges.end()),
546c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        FixedSizePortion(FixedSizePortion) {}
547c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
548c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Accessors
549c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
550c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> getRanges() const {
551c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Ranges;
552c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
553c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
554c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  StringRef getFixedSizePortion() const { return FixedSizePortion; }
555c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
556c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
557c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCFragment *F) {
558c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return F->getKind() == MCFragment::FT_CVDefRange;
559c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
560c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
561c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
562c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm
563c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
564c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_MC_MCFRAGMENT_H
565