LLVM  6.0.0svn
AArch64MCExpr.h
Go to the documentation of this file.
1 //=--- AArch64MCExpr.h - AArch64 specific MC expression classes ---*- C++ -*-=//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes AArch64-specific MCExprs, used for modifiers like
11 // ":lo12:" or ":gottprel_g1:".
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64MCEXPR_H
16 #define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64MCEXPR_H
17 
18 #include "llvm/MC/MCExpr.h"
20 
21 namespace llvm {
22 
23 class AArch64MCExpr : public MCTargetExpr {
24 public:
25  enum VariantKind {
26  VK_NONE = 0x000,
27 
28  // Symbol locations specifying (roughly speaking) what calculation should be
29  // performed to construct the final address for the relocated
30  // symbol. E.g. direct, via the GOT, ...
31  VK_ABS = 0x001,
32  VK_SABS = 0x002,
33  VK_GOT = 0x003,
34  VK_DTPREL = 0x004,
35  VK_GOTTPREL = 0x005,
36  VK_TPREL = 0x006,
37  VK_TLSDESC = 0x007,
38  VK_SymLocBits = 0x00f,
39 
40  // Variants specifying which part of the final address calculation is
41  // used. E.g. the low 12 bits for an ADD/LDR, the middle 16 bits for a
42  // MOVZ/MOVK.
43  VK_PAGE = 0x010,
44  VK_PAGEOFF = 0x020,
45  VK_HI12 = 0x030,
46  VK_G0 = 0x040,
47  VK_G1 = 0x050,
48  VK_G2 = 0x060,
49  VK_G3 = 0x070,
51 
52  // Whether the final relocation is a checked one (where a linker should
53  // perform a range-check on the final address) or not. Note that this field
54  // is unfortunately sometimes omitted from the assembly syntax. E.g. :lo12:
55  // on its own is a non-checked relocation. We side with ELF on being
56  // explicit about this!
57  VK_NC = 0x100,
58 
59  // Convenience definitions for referring to specific textual representations
60  // of relocation specifiers. Note that this means the "_NC" is sometimes
61  // omitted in line with assembly syntax here (VK_LO12 rather than VK_LO12_NC
62  // since a user would write ":lo12:").
101 
102  VK_INVALID = 0xfff
103  };
104 
105 private:
106  const MCExpr *Expr;
107  const VariantKind Kind;
108 
109  explicit AArch64MCExpr(const MCExpr *Expr, VariantKind Kind)
110  : Expr(Expr), Kind(Kind) {}
111 
112 public:
113  /// @name Construction
114  /// @{
115 
116  static const AArch64MCExpr *create(const MCExpr *Expr, VariantKind Kind,
117  MCContext &Ctx);
118 
119  /// @}
120  /// @name Accessors
121  /// @{
122 
123  /// Get the kind of this expression.
124  VariantKind getKind() const { return Kind; }
125 
126  /// Get the expression this modifier applies to.
127  const MCExpr *getSubExpr() const { return Expr; }
128 
129  /// @}
130  /// @name VariantKind information extractors.
131  /// @{
132 
134  return static_cast<VariantKind>(Kind & VK_SymLocBits);
135  }
136 
138  return static_cast<VariantKind>(Kind & VK_AddressFragBits);
139  }
140 
141  static bool isNotChecked(VariantKind Kind) { return Kind & VK_NC; }
142 
143  /// @}
144 
145  /// Convert the variant kind into an ELF-appropriate modifier
146  /// (e.g. ":got:", ":lo12:").
148 
149  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
150 
151  void visitUsedExpr(MCStreamer &Streamer) const override;
152 
153  MCFragment *findAssociatedFragment() const override;
154 
155  bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
156  const MCFixup *Fixup) const override;
157 
158  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
159 
160  static bool classof(const MCExpr *E) {
161  return E->getKind() == MCExpr::Target;
162  }
163 
164  static bool classof(const AArch64MCExpr *) { return true; }
165 };
166 } // end namespace llvm
167 
168 #endif
VariantKind getKind() const
Get the kind of this expression.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
static const AArch64MCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
static bool classof(const AArch64MCExpr *)
StringRef getVariantKindName() const
Convert the variant kind into an ELF-appropriate modifier (e.g.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:66
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:563
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Context object for machine code objects.
Definition: MCContext.h:59
static VariantKind getAddressFrag(VariantKind Kind)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Streaming machine code generation interface.
Definition: MCStreamer.h:169
const MCExpr * getSubExpr() const
Get the expression this modifier applies to.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void visitUsedExpr(MCStreamer &Streamer) const override
PowerPC TLS Dynamic Call Fixup
ExprKind getKind() const
Definition: MCExpr.h:73
static bool isNotChecked(VariantKind Kind)
static bool classof(const MCExpr *E)
static VariantKind getSymbolLoc(VariantKind Kind)
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Target specific expression.
Definition: MCExpr.h:43
MCFragment * findAssociatedFragment() const override