LLVM  10.0.0svn
MipsAsmBackend.h
Go to the documentation of this file.
1 //===-- MipsAsmBackend.h - Mips Asm 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 // This file defines the MipsAsmBackend class.
10 //
11 //===----------------------------------------------------------------------===//
12 //
13 
14 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
15 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
16 
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/MC/MCAsmBackend.h"
20 
21 namespace llvm {
22 
23 class MCAssembler;
24 struct MCFixupKindInfo;
25 class MCObjectWriter;
26 class MCRegisterInfo;
27 class MCSymbolELF;
28 class Target;
29 
30 class MipsAsmBackend : public MCAsmBackend {
31  Triple TheTriple;
32  bool IsN32;
33 
34 public:
35  MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT,
36  StringRef CPU, bool N32)
37  : MCAsmBackend(TT.isLittleEndian() ? support::little : support::big),
38  TheTriple(TT), IsN32(N32) {}
39 
40  std::unique_ptr<MCObjectTargetWriter>
41  createObjectTargetWriter() const override;
42 
43  void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
45  uint64_t Value, bool IsResolved,
46  const MCSubtargetInfo *STI) const override;
47 
49  const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
50 
51  unsigned getNumFixupKinds() const override {
53  }
54 
55  /// @name Target Relaxation Interfaces
56  /// @{
57 
58  /// MayNeedRelaxation - Check whether the given instruction may need
59  /// relaxation.
60  ///
61  /// \param Inst - The instruction to test.
62  bool mayNeedRelaxation(const MCInst &Inst,
63  const MCSubtargetInfo &STI) const override {
64  return false;
65  }
66 
67  /// fixupNeedsRelaxation - Target specific predicate for whether a given
68  /// fixup requires the associated instruction to be relaxed.
69  bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
70  const MCRelaxableFragment *DF,
71  const MCAsmLayout &Layout) const override {
72  // FIXME.
73  llvm_unreachable("RelaxInstruction() unimplemented");
74  return false;
75  }
76 
77  /// RelaxInstruction - Relax the instruction in the given fragment
78  /// to the next wider instruction.
79  ///
80  /// \param Inst - The instruction to relax, which may be the same
81  /// as the output.
82  /// \param [out] Res On return, the relaxed instruction.
83  void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
84  MCInst &Res) const override {}
85 
86  /// @}
87 
88  bool writeNopData(raw_ostream &OS, uint64_t Count) const override;
89 
90  bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
91  const MCValue &Target) override;
92 
93  bool isMicroMips(const MCSymbol *Sym) const override;
94 }; // class MipsAsmBackend
95 
96 } // namespace
97 
98 #endif
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override
ApplyFixup - Apply the Value for given Fixup into the provided data fragment, at the offset specified...
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const override
MayNeedRelaxation - Check whether the given instruction may need relaxation.
This represents an "assembler immediate".
Definition: MCValue.h:39
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target) override
Hook to check if a relocation is needed for some target specific reason.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:77
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
unsigned getNumFixupKinds() const override
Get the number of target specific fixup kinds.
MipsAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, bool N32)
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:158
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:272
unsigned const MachineRegisterInfo * MRI
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:290
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:22
bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const override
fixupNeedsRelaxation - Target specific predicate for whether a given fixup requires the associated in...
bool writeNopData(raw_ostream &OS, uint64_t Count) const override
WriteNopData - Write an (optimal) nop sequence of Count bytes to the given output.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
PowerPC TLS Dynamic Call Fixup
Target - Wrapper for Target specific information.
void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const override
RelaxInstruction - Relax the instruction in the given fragment to the next wider instruction.
bool isMicroMips(const MCSymbol *Sym) const override
Check whether a given symbol has been flagged with MICROMIPS flag.
Generic base class for all target subtargets.
Optional< MCFixupKind > getFixupKind(StringRef Name) const override
Map a relocation name used in .reloc to a fixup kind.
Target independent information on a fixup kind.
LLVM Value Representation.
Definition: Value.h:74
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:41
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48