LLVM 22.0.0git
RISCVAsmBackend.h
Go to the documentation of this file.
1//===-- RISCVAsmBackend.h - RISC-V Assembler Backend ----------------------===//
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#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVASMBACKEND_H
10#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVASMBACKEND_H
11
15#include "llvm/ADT/StringMap.h"
18
19namespace llvm {
20class MCAssembler;
22class raw_ostream;
23
25protected:
28 bool Is64Bit;
30 // Temporary symbol used to check whether a PC-relative fixup is resolved.
31 MCSymbol *PCRelTemp = nullptr;
32
33 bool isPCRelFixupResolved(const MCSymbol *SymA, const MCFragment &F);
34
36
37public:
39 bool IsLittleEndian, const MCTargetOptions &Options);
40 ~RISCVAsmBackend() override = default;
41
42 std::optional<bool> evaluateFixup(const MCFragment &, MCFixup &, MCValue &,
43 uint64_t &) override;
44 bool addReloc(const MCFragment &, const MCFixup &, const MCValue &,
45 uint64_t &FixedValue, bool IsResolved);
46
47 void maybeAddVendorReloc(const MCFragment &, const MCFixup &);
48
49 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
50 uint8_t *Data, uint64_t Value, bool IsResolved) override;
51
52 std::unique_ptr<MCObjectTargetWriter>
53 createObjectTargetWriter() const override;
54
56 const MCValue &, uint64_t,
57 bool) const override;
58
59 std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;
60
61 MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override;
62
63 bool mayNeedRelaxation(unsigned Opcode, ArrayRef<MCOperand> Operands,
64 const MCSubtargetInfo &STI) const override;
65 void relaxInstruction(MCInst &Inst,
66 const MCSubtargetInfo &STI) const override;
67
68 bool relaxAlign(MCFragment &F, unsigned &Size) override;
69 bool relaxDwarfLineAddr(MCFragment &) const override;
70 bool relaxDwarfCFA(MCFragment &) const override;
71 std::pair<bool, bool> relaxLEB128(MCFragment &LF,
72 int64_t &Value) const override;
73
75 const MCSubtargetInfo *STI) const override;
76
78};
79}
80
81#endif
This file defines the StringMap class.
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:54
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
MCAsmBackend(llvm::endianness Endian)
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Base class for classes that define behaviour that is specific to both the target and the object forma...
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
std::optional< bool > evaluateFixup(const MCFragment &, MCFixup &, MCValue &, uint64_t &) override
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
bool isPCRelFixupResolved(const MCSymbol *SymA, const MCFragment &F)
void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override
Relax the instruction in the given fragment to the next wider instruction.
bool relaxAlign(MCFragment &F, unsigned &Size) override
const MCTargetOptions & getTargetOptions() const
bool addReloc(const MCFragment &, const MCFixup &, const MCValue &, uint64_t &FixedValue, bool IsResolved)
MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
RISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, bool IsLittleEndian, const MCTargetOptions &Options)
std::pair< bool, bool > relaxLEB128(MCFragment &LF, int64_t &Value) const override
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, uint8_t *Data, uint64_t Value, bool IsResolved) override
bool writeNopData(raw_ostream &OS, uint64_t Count, const MCSubtargetInfo *STI) const override
Write an (optimal) nop sequence of Count bytes to the given output.
const MCSubtargetInfo & STI
void maybeAddVendorReloc(const MCFragment &, const MCFixup &)
StringMap< MCSymbol * > VendorSymbols
bool mayNeedRelaxation(unsigned Opcode, ArrayRef< MCOperand > Operands, const MCSubtargetInfo &STI) const override
Check whether the given instruction (encoded as Opcode+Operands) may need relaxation.
const MCTargetOptions & TargetOptions
bool fixupNeedsRelaxationAdvanced(const MCFragment &, const MCFixup &, const MCValue &, uint64_t, bool) const override
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed...
~RISCVAsmBackend() override=default
std::optional< MCFixupKind > getFixupKind(StringRef Name) const override
Map a relocation name used in .reloc to a fixup kind.
bool relaxDwarfCFA(MCFragment &) const override
bool relaxDwarfLineAddr(MCFragment &) const override
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Target - Wrapper for Target specific information.
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition MCFixup.h:22
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
Target independent information on a fixup kind.