1 //===-- RISCVMCExpr.h - RISCV specific MC expression classes ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes RISCV-specific MCExprs, used for modifiers like
11 // "%hi" or "%lo" etc.,
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H
16 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H
18 #include "llvm/MC/MCExpr.h"
24 class RISCVMCExpr
: public MCTargetExpr
{
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
) {}
46 static const RISCVMCExpr
*create(const MCExpr
*Expr
, VariantKind Kind
,
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
{
58 return getSubExpr()->findAssociatedFragment();
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
;
70 static bool classof(const RISCVMCExpr
*) { return true; }
72 static VariantKind
getVariantKindForName(StringRef name
);
73 static StringRef
getVariantKindName(VariantKind Kind
);
76 } // end namespace llvm.