2014-03-20 17:29:54 +08:00
|
|
|
//===-- MipsMCCodeEmitter.h - Convert Mips Code to Machine Code -----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the MipsMCCodeEmitter class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCCODEEMITTER_H
|
|
|
|
#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCCODEEMITTER_H
|
2014-03-20 17:29:54 +08:00
|
|
|
|
|
|
|
#include "llvm/MC/MCCodeEmitter.h"
|
|
|
|
#include "llvm/Support/DataTypes.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MCContext;
|
|
|
|
class MCExpr;
|
|
|
|
class MCInst;
|
|
|
|
class MCInstrInfo;
|
|
|
|
class MCFixup;
|
|
|
|
class MCOperand;
|
|
|
|
class MCSubtargetInfo;
|
|
|
|
class raw_ostream;
|
|
|
|
|
|
|
|
class MipsMCCodeEmitter : public MCCodeEmitter {
|
|
|
|
MipsMCCodeEmitter(const MipsMCCodeEmitter &) LLVM_DELETED_FUNCTION;
|
|
|
|
void operator=(const MipsMCCodeEmitter &) LLVM_DELETED_FUNCTION;
|
|
|
|
const MCInstrInfo &MCII;
|
|
|
|
MCContext &Ctx;
|
|
|
|
bool IsLittleEndian;
|
|
|
|
|
|
|
|
bool isMicroMips(const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
MipsMCCodeEmitter(const MCInstrInfo &mcii, MCContext &Ctx_, bool IsLittle)
|
|
|
|
: MCII(mcii), Ctx(Ctx_), IsLittleEndian(IsLittle) {}
|
|
|
|
|
|
|
|
~MipsMCCodeEmitter() {}
|
|
|
|
|
|
|
|
void EmitByte(unsigned char C, raw_ostream &OS) const;
|
|
|
|
|
|
|
|
void EmitInstruction(uint64_t Val, unsigned Size, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &OS) const;
|
|
|
|
|
|
|
|
void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
2014-04-29 15:58:02 +08:00
|
|
|
const MCSubtargetInfo &STI) const override;
|
2014-03-20 17:29:54 +08:00
|
|
|
|
|
|
|
// getBinaryCodeForInstr - TableGen'erated function for getting the
|
|
|
|
// binary encoding for an instruction.
|
|
|
|
uint64_t getBinaryCodeForInstr(const MCInst &MI,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-11-19 03:20:34 +08:00
|
|
|
// getJumpTargetOpValue - Return binary encoding of the jump
|
2014-03-20 17:29:54 +08:00
|
|
|
// target operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getJumpTargetOpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
// getBranchJumpOpValueMM - Return binary encoding of the microMIPS jump
|
|
|
|
// target operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getJumpTargetOpValueMM(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-09-12 22:29:54 +08:00
|
|
|
|
|
|
|
// getUImm5Lsl2Encoding - Return binary encoding of the microMIPS jump
|
|
|
|
// target operand.
|
|
|
|
unsigned getUImm5Lsl2Encoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-10-10 22:37:30 +08:00
|
|
|
|
2014-10-23 19:06:34 +08:00
|
|
|
unsigned getSImm3Lsa2Value(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-10-23 19:13:59 +08:00
|
|
|
unsigned getUImm6Lsl2Encoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-10-10 22:37:30 +08:00
|
|
|
// getSImm9AddiuspValue - Return binary encoding of the microMIPS addiusp
|
|
|
|
// instruction immediate operand.
|
|
|
|
unsigned getSImm9AddiuspValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-03-20 17:29:54 +08:00
|
|
|
|
|
|
|
// getBranchTargetOpValue - Return binary encoding of the branch
|
|
|
|
// target operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getBranchTargetOpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2015-01-12 20:03:34 +08:00
|
|
|
// getBranchTarget7OpValue - Return binary encoding of the microMIPS branch
|
|
|
|
// target operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getBranchTarget7OpValueMM(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2015-01-21 20:39:30 +08:00
|
|
|
// getBranchTargetOpValueMMPC10 - Return binary encoding of the microMIPS
|
|
|
|
// 10-bit branch target operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getBranchTargetOpValueMMPC10(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-03-20 17:29:54 +08:00
|
|
|
// getBranchTargetOpValue - Return binary encoding of the microMIPS branch
|
|
|
|
// target operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getBranchTargetOpValueMM(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
2014-05-16 19:03:45 +08:00
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
// getBranchTarget21OpValue - Return binary encoding of the branch
|
|
|
|
// offset operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getBranchTarget21OpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
// getBranchTarget26OpValue - Return binary encoding of the branch
|
|
|
|
// offset operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getBranchTarget26OpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
2014-03-20 17:29:54 +08:00
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-05-16 21:19:46 +08:00
|
|
|
// getJumpOffset16OpValue - Return binary encoding of the jump
|
|
|
|
// offset operand. If the machine operand requires relocation,
|
|
|
|
// record the relocation and return zero.
|
|
|
|
unsigned getJumpOffset16OpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-03-20 17:29:54 +08:00
|
|
|
// getMachineOpValue - Return binary encoding of operand. If the machin
|
|
|
|
// operand requires relocation, record the relocation and return zero.
|
|
|
|
unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
unsigned getMSAMemEncoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
unsigned getMemEncoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-11-24 22:39:13 +08:00
|
|
|
unsigned getMemEncodingMMImm4(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
unsigned getMemEncodingMMImm4Lsl1(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
unsigned getMemEncodingMMImm4Lsl2(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-12-24 00:16:33 +08:00
|
|
|
unsigned getMemEncodingMMSPImm5Lsl2(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-03-20 17:29:54 +08:00
|
|
|
unsigned getMemEncodingMMImm12(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-11-28 02:28:59 +08:00
|
|
|
unsigned getMemEncodingMMImm4sp(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-03-20 17:29:54 +08:00
|
|
|
unsigned getSizeExtEncoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
unsigned getSizeInsEncoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
|
|
|
// getLSAImmEncoding - Return binary encoding of LSA immediate.
|
|
|
|
unsigned getLSAImmEncoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-05-15 18:45:58 +08:00
|
|
|
unsigned getSimm19Lsl2Encoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-06-09 17:49:51 +08:00
|
|
|
unsigned getSimm18Lsl3Encoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-10-23 18:42:01 +08:00
|
|
|
unsigned getUImm3Mod8Encoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-11-06 01:31:00 +08:00
|
|
|
unsigned getUImm4AndValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-10-23 18:42:01 +08:00
|
|
|
|
2014-12-16 22:59:10 +08:00
|
|
|
unsigned getRegisterPairOpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2015-01-21 20:10:11 +08:00
|
|
|
unsigned getSimm23Lsl2Encoding(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-03-20 17:29:54 +08:00
|
|
|
unsigned getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
|
|
|
|
2014-11-20 00:44:02 +08:00
|
|
|
unsigned getRegisterListOpValue(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-11-28 02:28:59 +08:00
|
|
|
|
|
|
|
unsigned getRegisterListOpValue16(const MCInst &MI, unsigned OpNo,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups,
|
|
|
|
const MCSubtargetInfo &STI) const;
|
2014-03-20 17:29:54 +08:00
|
|
|
}; // class MipsMCCodeEmitter
|
2014-03-21 18:35:14 +08:00
|
|
|
} // namespace llvm.
|
2014-03-20 17:29:54 +08:00
|
|
|
|
|
|
|
#endif
|