LLVM  8.0.0svn
Go to the documentation of this file.
1 //===-- RISCVMCExpr.h - RISCV 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 RISCV-specific MCExprs, used for modifiers like
11 // "%hi" or "%lo" etc.,
12 //
13 //===----------------------------------------------------------------------===//
18 #include "llvm/MC/MCExpr.h"
20 namespace llvm {
22 class StringRef;
23 class MCOperand;
24 class RISCVMCExpr : public MCTargetExpr {
25 public:
26  enum VariantKind {
34  };
36 private:
37  const MCExpr *Expr;
38  const VariantKind Kind;
40  int64_t evaluateAsInt64(int64_t Value) const;
42  explicit RISCVMCExpr(const MCExpr *Expr, VariantKind Kind)
43  : Expr(Expr), Kind(Kind) {}
45 public:
46  static const RISCVMCExpr *create(const MCExpr *Expr, VariantKind Kind,
47  MCContext &Ctx);
49  VariantKind getKind() const { return Kind; }
51  const MCExpr *getSubExpr() const { return Expr; }
53  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
54  bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
55  const MCFixup *Fixup) const override;
56  void visitUsedExpr(MCStreamer &Streamer) const override;
57  MCFragment *findAssociatedFragment() const override {
59  }
61  // There are no TLS RISCVMCExprs at the moment.
62  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
64  bool evaluateAsConstant(int64_t &Res) const;
66  static bool classof(const MCExpr *E) {
67  return E->getKind() == MCExpr::Target;
68  }
70  static bool classof(const RISCVMCExpr *) { return true; }
74 };
76 } // end namespace llvm.
78 #endif
static bool classof(const MCExpr *E)
Definition: RISCVMCExpr.h:66
bool evaluateAsConstant(int64_t &Res) const
Definition: RISCVMCExpr.cpp:93
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: RISCVMCExpr.cpp:33
VariantKind getKind() const
Definition: RISCVMCExpr.h:49
static StringRef getVariantKindName(VariantKind Kind)
Definition: RISCVMCExpr.cpp:78
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:74
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:581
Context object for machine code objects.
Definition: MCContext.h:63
const MCExpr * getSubExpr() const
Definition: RISCVMCExpr.h:51
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:188
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
PowerPC TLS Dynamic Call Fixup
ExprKind getKind() const
Definition: MCExpr.h:73
static bool classof(const RISCVMCExpr *)
Definition: RISCVMCExpr.h:70
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:862
MCFragment * findAssociatedFragment() const override
Definition: RISCVMCExpr.h:57
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: RISCVMCExpr.cpp:43
static VariantKind getVariantKindForName(StringRef name)
Definition: RISCVMCExpr.cpp:69
LLVM Value Representation.
Definition: Value.h:73
static const char * name
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: RISCVMCExpr.h:62
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Target specific expression.
Definition: MCExpr.h:43
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: RISCVMCExpr.cpp:65
static const RISCVMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
Definition: RISCVMCExpr.cpp:28