brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 5152d05 Raw
81 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVASMBACKEND_H10#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVASMBACKEND_H11 12#include "MCTargetDesc/RISCVBaseInfo.h"13#include "MCTargetDesc/RISCVFixupKinds.h"14#include "MCTargetDesc/RISCVMCTargetDesc.h"15#include "llvm/ADT/StringMap.h"16#include "llvm/MC/MCAsmBackend.h"17#include "llvm/MC/MCSubtargetInfo.h"18 19namespace llvm {20class MCAssembler;21class MCObjectTargetWriter;22class raw_ostream;23 24class RISCVAsmBackend : public MCAsmBackend {25  const MCSubtargetInfo &STI;26  uint8_t OSABI;27  bool Is64Bit;28  const MCTargetOptions &TargetOptions;29  // Temporary symbol used to check whether a PC-relative fixup is resolved.30  MCSymbol *PCRelTemp = nullptr;31 32  bool isPCRelFixupResolved(const MCSymbol *SymA, const MCFragment &F);33 34  StringMap<MCSymbol *> VendorSymbols;35 36public:37  RISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit,38                  bool IsLittleEndian, const MCTargetOptions &Options);39  ~RISCVAsmBackend() override = default;40 41  std::optional<bool> evaluateFixup(const MCFragment &, MCFixup &, MCValue &,42                                    uint64_t &) override;43  bool addReloc(const MCFragment &, const MCFixup &, const MCValue &,44                uint64_t &FixedValue, bool IsResolved);45 46  void maybeAddVendorReloc(const MCFragment &, const MCFixup &);47 48  void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,49                  uint8_t *Data, uint64_t Value, bool IsResolved) override;50 51  std::unique_ptr<MCObjectTargetWriter>52  createObjectTargetWriter() const override;53 54  bool fixupNeedsRelaxationAdvanced(const MCFragment &, const MCFixup &,55                                    const MCValue &, uint64_t,56                                    bool) const override;57 58  std::optional<MCFixupKind> getFixupKind(StringRef Name) const override;59 60  MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override;61 62  bool mayNeedRelaxation(unsigned Opcode, ArrayRef<MCOperand> Operands,63                         const MCSubtargetInfo &STI) const override;64  void relaxInstruction(MCInst &Inst,65                        const MCSubtargetInfo &STI) const override;66 67  bool relaxAlign(MCFragment &F, unsigned &Size) override;68  bool relaxDwarfLineAddr(MCFragment &) const override;69  bool relaxDwarfCFA(MCFragment &) const override;70  std::pair<bool, bool> relaxLEB128(MCFragment &LF,71                                    int64_t &Value) const override;72 73  bool writeNopData(raw_ostream &OS, uint64_t Count,74                    const MCSubtargetInfo *STI) const override;75 76  const MCTargetOptions &getTargetOptions() const { return TargetOptions; }77};78}79 80#endif81