LLVM  4.0.0
MipsAsmBackend.h
Go to the documentation of this file.
1 //===-- MipsAsmBackend.h - Mips Asm Backend ------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the MipsAsmBackend class.
11 //
12 //===----------------------------------------------------------------------===//
13 //
14 
15 #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
16 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
17 
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/MC/MCAsmBackend.h"
21 
22 namespace llvm {
23 
24 class MCAssembler;
25 struct MCFixupKindInfo;
26 class Target;
27 class MCObjectWriter;
28 
29 class MipsAsmBackend : public MCAsmBackend {
30  Triple::OSType OSType;
31  bool IsLittle; // Big or little endian
32  bool Is64Bit; // 32 or 64 bit words
33 
34 public:
35  MipsAsmBackend(const Target &T, Triple::OSType OSType, bool IsLittle,
36  bool Is64Bit)
37  : MCAsmBackend(), OSType(OSType), IsLittle(IsLittle), Is64Bit(Is64Bit) {}
38 
40 
41  void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
42  uint64_t Value, bool IsPCRel) const override;
43 
45  const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
46 
47  unsigned getNumFixupKinds() const override {
49  }
50 
51  /// @name Target Relaxation Interfaces
52  /// @{
53 
54  /// MayNeedRelaxation - Check whether the given instruction may need
55  /// relaxation.
56  ///
57  /// \param Inst - The instruction to test.
58  bool mayNeedRelaxation(const MCInst &Inst) const override {
59  return false;
60  }
61 
62  /// fixupNeedsRelaxation - Target specific predicate for whether a given
63  /// fixup requires the associated instruction to be relaxed.
64  bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
65  const MCRelaxableFragment *DF,
66  const MCAsmLayout &Layout) const override {
67  // FIXME.
68  llvm_unreachable("RelaxInstruction() unimplemented");
69  return false;
70  }
71 
72  /// RelaxInstruction - Relax the instruction in the given fragment
73  /// to the next wider instruction.
74  ///
75  /// \param Inst - The instruction to relax, which may be the same
76  /// as the output.
77  /// \param [out] Res On return, the relaxed instruction.
78  void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
79  MCInst &Res) const override {}
80 
81  /// @}
82 
83  bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
84 
85  void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
86  const MCFixup &Fixup, const MCFragment *DF,
87  const MCValue &Target, uint64_t &Value,
88  bool &IsResolved) override;
89 
90 }; // class MipsAsmBackend
91 
92 } // namespace
93 
94 #endif
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value, bool IsPCRel) const override
ApplyFixup - Apply the Value for given Fixup into the provided data fragment, at the offset specified...
This represents an "assembler immediate".
Definition: MCValue.h:40
Defines the object file and target independent interfaces used by the assembler backend to write nati...
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:66
void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFixup &Fixup, const MCFragment *DF, const MCValue &Target, uint64_t &Value, bool &IsResolved) override
processFixupValue - Target hook to process the literal value of a fixup if necessary.
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
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.
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override
WriteNopData - Write an (optimal) nop sequence of Count bytes to the given output.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:249
MCObjectWriter * createObjectWriter(raw_pwrite_stream &OS) const override
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file...
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:23
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...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool mayNeedRelaxation(const MCInst &Inst) const override
MayNeedRelaxation - Check whether the given instruction may need relaxation.
static const char * Target
Target - Wrapper for Target specific information.
MipsAsmBackend(const Target &T, Triple::OSType OSType, bool IsLittle, bool Is64Bit)
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.
MCSubtargetInfo - 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.
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
const unsigned Kind
LLVM Value Representation.
Definition: Value.h:71
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47