LLVM 20.0.0git
RISCVMCExpr.h
Go to the documentation of this file.
1//===-- RISCVMCExpr.h - RISC-V specific MC expression classes----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file describes RISC-V specific MCExprs, used for modifiers like
10// "%hi" or "%lo" etc.,
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H
15#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H
16
17#include "llvm/MC/MCExpr.h"
18
19namespace llvm {
20
21class StringRef;
22
23class RISCVMCExpr : public MCTargetExpr {
24public:
44 VK_RISCV_Invalid // Must be the last item
45 };
46
47private:
48 const MCExpr *Expr;
49 const VariantKind Kind;
50
51 int64_t evaluateAsInt64(int64_t Value) const;
52
53 explicit RISCVMCExpr(const MCExpr *Expr, VariantKind Kind)
54 : Expr(Expr), Kind(Kind) {}
55
56public:
57 static const RISCVMCExpr *create(const MCExpr *Expr, VariantKind Kind,
58 MCContext &Ctx);
59
60 VariantKind getKind() const { return Kind; }
61
62 const MCExpr *getSubExpr() const { return Expr; }
63
64 /// Get the corresponding PC-relative HI fixup that a VK_RISCV_PCREL_LO
65 /// points to, and optionally the fragment containing it.
66 ///
67 /// \returns nullptr if this isn't a VK_RISCV_PCREL_LO pointing to a
68 /// known PC-relative HI fixup.
69 const MCFixup *getPCRelHiFixup(const MCFragment **DFOut) const;
70
71 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
72 bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
73 const MCFixup *Fixup) const override;
74 void visitUsedExpr(MCStreamer &Streamer) const override;
77 }
78
79 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
80
81 bool evaluateAsConstant(int64_t &Res) const;
82
83 static bool classof(const MCExpr *E) {
84 return E->getKind() == MCExpr::Target;
85 }
86
89};
90
91} // end namespace llvm.
92
93#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
PowerPC TLS Dynamic Call Fixup
static const char * name
Definition: SMEABIPass.cpp:46
raw_pwrite_stream & OS
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
@ Target
Target specific expression.
Definition: MCExpr.h:41
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:1060
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
Streaming machine code generation interface.
Definition: MCStreamer.h:213
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:657
This represents an "assembler immediate".
Definition: MCValue.h:36
VariantKind getKind() const
Definition: RISCVMCExpr.h:60
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
static const RISCVMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
Definition: RISCVMCExpr.cpp:30
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: RISCVMCExpr.cpp:35
const MCFixup * getPCRelHiFixup(const MCFragment **DFOut) const
Get the corresponding PC-relative HI fixup that a VK_RISCV_PCREL_LO points to, and optionally the fra...
Definition: RISCVMCExpr.cpp:47
void visitUsedExpr(MCStreamer &Streamer) const override
bool evaluateAsConstant(int64_t &Res) const
static bool classof(const MCExpr *E)
Definition: RISCVMCExpr.h:83
static StringRef getVariantKindName(VariantKind Kind)
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const override
Definition: RISCVMCExpr.cpp:91
const MCExpr * getSubExpr() const
Definition: RISCVMCExpr.h:62
MCFragment * findAssociatedFragment() const override
Definition: RISCVMCExpr.h:75
static VariantKind getVariantKindForName(StringRef name)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18