blob: d5c3dbc4788089c2e1951f5db9fb05b9dffcf32d [file] [log] [blame]
Zoran Jovanovicada38ef2014-03-27 12:38:40 +00001//===-- 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 MIPSASMBACKEND_H
16#define MIPSASMBACKEND_H
17
18#include "MCTargetDesc/MipsFixupKinds.h"
19#include "llvm/MC/MCAsmBackend.h"
20#include "llvm/ADT/Triple.h"
21
22namespace llvm {
23
24class MCAssembler;
Aaron Ballmanbe648a32014-03-27 14:10:00 +000025struct MCFixupKindInfo;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000026class Target;
27class MCObjectWriter;
28
29class MipsAsmBackend : public MCAsmBackend {
30 Triple::OSType OSType;
31 bool IsLittle; // Big or little endian
32 bool Is64Bit; // 32 or 64 bit words
33
34public:
35 MipsAsmBackend(const Target &T, Triple::OSType _OSType, bool _isLittle,
36 bool _is64Bit)
37 : MCAsmBackend(), OSType(_OSType), IsLittle(_isLittle),
38 Is64Bit(_is64Bit) {}
39
Craig Topper56c590a2014-04-29 07:58:02 +000040 MCObjectWriter *createObjectWriter(raw_ostream &OS) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000041
42 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
Craig Topper56c590a2014-04-29 07:58:02 +000043 uint64_t Value, bool IsPCRel) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000044
Craig Topper56c590a2014-04-29 07:58:02 +000045 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000046
Craig Topper56c590a2014-04-29 07:58:02 +000047 unsigned getNumFixupKinds() const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000048 return Mips::NumTargetFixupKinds;
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.
Craig Topper56c590a2014-04-29 07:58:02 +000058 bool mayNeedRelaxation(const MCInst &Inst) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000059 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,
Craig Topper56c590a2014-04-29 07:58:02 +000066 const MCAsmLayout &Layout) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000067 // FIXME.
Craig Topper35b2f752014-06-19 06:10:58 +000068 llvm_unreachable("RelaxInstruction() unimplemented");
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000069 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.
Craig Topper56c590a2014-04-29 07:58:02 +000078 void relaxInstruction(const MCInst &Inst, MCInst &Res) const override {}
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000079
80 /// @}
81
Craig Topper56c590a2014-04-29 07:58:02 +000082 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000083
84 void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
85 const MCFixup &Fixup, const MCFragment *DF,
Rafael Espindola3e3de5e2014-03-28 16:06:09 +000086 const MCValue &Target, uint64_t &Value,
Craig Topper56c590a2014-04-29 07:58:02 +000087 bool &IsResolved) override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000088
89}; // class MipsAsmBackend
90
91} // namespace
92
93#endif