blob: b3d5a4964f86c78e40ec1f623e8f780dfe79402b [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
41 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
Craig Topper56c590a2014-04-29 07:58:02 +000042 uint64_t Value, bool IsPCRel) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000043
Craig Topper56c590a2014-04-29 07:58:02 +000044 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000045
Craig Topper56c590a2014-04-29 07:58:02 +000046 unsigned getNumFixupKinds() const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000047 return Mips::NumTargetFixupKinds;
48 }
49
50 /// @name Target Relaxation Interfaces
51 /// @{
52
53 /// MayNeedRelaxation - Check whether the given instruction may need
54 /// relaxation.
55 ///
56 /// \param Inst - The instruction to test.
Craig Topper56c590a2014-04-29 07:58:02 +000057 bool mayNeedRelaxation(const MCInst &Inst) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000058 return false;
59 }
60
61 /// fixupNeedsRelaxation - Target specific predicate for whether a given
62 /// fixup requires the associated instruction to be relaxed.
63 bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
64 const MCRelaxableFragment *DF,
Craig Topper56c590a2014-04-29 07:58:02 +000065 const MCAsmLayout &Layout) const override {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000066 // FIXME.
Craig Topper35b2f752014-06-19 06:10:58 +000067 llvm_unreachable("RelaxInstruction() unimplemented");
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000068 return false;
69 }
70
71 /// RelaxInstruction - Relax the instruction in the given fragment
72 /// to the next wider instruction.
73 ///
74 /// \param Inst - The instruction to relax, which may be the same
75 /// as the output.
76 /// \param [out] Res On return, the relaxed instruction.
Craig Topper56c590a2014-04-29 07:58:02 +000077 void relaxInstruction(const MCInst &Inst, MCInst &Res) const override {}
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000078
79 /// @}
80
Craig Topper56c590a2014-04-29 07:58:02 +000081 bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000082
83 void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
84 const MCFixup &Fixup, const MCFragment *DF,
Rafael Espindola3e3de5e2014-03-28 16:06:09 +000085 const MCValue &Target, uint64_t &Value,
Craig Topper56c590a2014-04-29 07:58:02 +000086 bool &IsResolved) override;
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000087
88}; // class MipsAsmBackend
89
Alexander Kornienkof00654e2015-06-23 09:49:53 +000090} // namespace
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000091
92#endif