blob: a1068dccf6dab19eb3b1679cf5a22595b89f457b [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
16#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000017
18#include "MCTargetDesc/MipsFixupKinds.h"
Daniel Sanders50f17232015-09-15 16:17:27 +000019#include "llvm/ADT/Triple.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000020#include "llvm/MC/MCAsmBackend.h"
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000021
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 {
Daniel Sanders50f17232015-09-15 16:17:27 +000030 Triple::OSType OSType;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000031 bool IsLittle; // Big or little endian
32 bool Is64Bit; // 32 or 64 bit words
33
34public:
Daniel Sanders50f17232015-09-15 16:17:27 +000035 MipsAsmBackend(const Target &T, Triple::OSType OSType, bool IsLittle,
David Blaikie9f380a32015-03-16 18:06:57 +000036 bool Is64Bit)
37 : MCAsmBackend(), OSType(OSType), IsLittle(IsLittle), Is64Bit(Is64Bit) {}
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000038
Rafael Espindola5560a4c2015-04-14 22:14:34 +000039 MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000040
Rafael Espindola801b42d2017-06-23 22:52:36 +000041 void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
42 const MCValue &Target, MutableArrayRef<char> Data,
Alex Bradbury866113c2017-04-05 10:16:14 +000043 uint64_t Value, bool IsPCRel, MCContext &Ctx) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000044
David Majnemerce108422016-01-19 23:05:27 +000045 Optional<MCFixupKind> getFixupKind(StringRef Name) const override;
Craig Topper56c590a2014-04-29 07:58:02 +000046 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000047
Craig Topper56c590a2014-04-29 07:58:02 +000048 unsigned getNumFixupKinds() const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000049 return Mips::NumTargetFixupKinds;
50 }
51
52 /// @name Target Relaxation Interfaces
53 /// @{
54
55 /// MayNeedRelaxation - Check whether the given instruction may need
56 /// relaxation.
57 ///
58 /// \param Inst - The instruction to test.
Craig Topper56c590a2014-04-29 07:58:02 +000059 bool mayNeedRelaxation(const MCInst &Inst) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000060 return false;
61 }
62
63 /// fixupNeedsRelaxation - Target specific predicate for whether a given
64 /// fixup requires the associated instruction to be relaxed.
65 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
66 const MCRelaxableFragment *DF,
Craig Topper56c590a2014-04-29 07:58:02 +000067 const MCAsmLayout &Layout) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000068 // FIXME.
Craig Topper35b2f752014-06-19 06:10:58 +000069 llvm_unreachable("RelaxInstruction() unimplemented");
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000070 return false;
71 }
72
73 /// RelaxInstruction - Relax the instruction in the given fragment
74 /// to the next wider instruction.
75 ///
76 /// \param Inst - The instruction to relax, which may be the same
77 /// as the output.
78 /// \param [out] Res On return, the relaxed instruction.
Nirav Dave86030622016-07-11 14:23:53 +000079 void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
80 MCInst &Res) const override {}
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000081
82 /// @}
83
Craig Topper56c590a2014-04-29 07:58:02 +000084 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000085
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000086}; // class MipsAsmBackend
87
Alexander Kornienkof00654e2015-06-23 09:49:53 +000088} // namespace
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000089
90#endif