Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h
35294 views
//=== MipsInstPrinter.h - Convert Mips MCInst to assembly syntax -*- C++ -*-==//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This class prints a Mips MCInst to a .s file.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSINSTPRINTER_H13#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSINSTPRINTER_H14#include "llvm/MC/MCInstPrinter.h"1516namespace llvm {17// These enumeration declarations were originally in MipsInstrInfo.h but18// had to be moved here to avoid circular dependencies between19// LLVMMipsCodeGen and LLVMMipsAsmPrinter.20namespace Mips {21// Mips Branch Codes22enum FPBranchCode {23BRANCH_F,24BRANCH_T,25BRANCH_FL,26BRANCH_TL,27BRANCH_INVALID28};2930// Mips Condition Codes31enum CondCode {32// To be used with float branch True33FCOND_F,34FCOND_UN,35FCOND_OEQ,36FCOND_UEQ,37FCOND_OLT,38FCOND_ULT,39FCOND_OLE,40FCOND_ULE,41FCOND_SF,42FCOND_NGLE,43FCOND_SEQ,44FCOND_NGL,45FCOND_LT,46FCOND_NGE,47FCOND_LE,48FCOND_NGT,4950// To be used with float branch False51// This conditions have the same mnemonic as the52// above ones, but are used with a branch False;53FCOND_T,54FCOND_OR,55FCOND_UNE,56FCOND_ONE,57FCOND_UGE,58FCOND_OGE,59FCOND_UGT,60FCOND_OGT,61FCOND_ST,62FCOND_GLE,63FCOND_SNE,64FCOND_GL,65FCOND_NLT,66FCOND_GE,67FCOND_NLE,68FCOND_GT69};7071const char *MipsFCCToString(Mips::CondCode CC);72} // end namespace Mips7374class MipsInstPrinter : public MCInstPrinter {75public:76MipsInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,77const MCRegisterInfo &MRI)78: MCInstPrinter(MAI, MII, MRI) {}7980// Autogenerated by tblgen.81std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;82void printInstruction(const MCInst *MI, uint64_t Address,83const MCSubtargetInfo &STI, raw_ostream &O);84static const char *getRegisterName(MCRegister Reg);8586void printRegName(raw_ostream &OS, MCRegister Reg) const override;87void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,88const MCSubtargetInfo &STI, raw_ostream &O) override;8990bool printAliasInstr(const MCInst *MI, uint64_t Address,91const MCSubtargetInfo &STI, raw_ostream &OS);92void printCustomAliasOperand(const MCInst *MI, uint64_t Address,93unsigned OpIdx, unsigned PrintMethodIdx,94const MCSubtargetInfo &STI, raw_ostream &O);9596private:97void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,98raw_ostream &O);99void printJumpOperand(const MCInst *MI, unsigned OpNo,100const MCSubtargetInfo &STI, raw_ostream &O);101void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo,102const MCSubtargetInfo &STI, raw_ostream &O);103template <unsigned Bits, unsigned Offset = 0>104void printUImm(const MCInst *MI, int opNum, const MCSubtargetInfo &STI,105raw_ostream &O);106void printMemOperand(const MCInst *MI, int opNum, const MCSubtargetInfo &STI,107raw_ostream &O);108void printMemOperandEA(const MCInst *MI, int opNum,109const MCSubtargetInfo &STI, raw_ostream &O);110void printFCCOperand(const MCInst *MI, int opNum, const MCSubtargetInfo &STI,111raw_ostream &O);112void printSHFMask(const MCInst *MI, int opNum, raw_ostream &O);113114bool printAlias(const char *Str, const MCInst &MI, uint64_t Address,115unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &OS,116bool IsBranch = false);117bool printAlias(const char *Str, const MCInst &MI, uint64_t Address,118unsigned OpNo0, unsigned OpNo1, const MCSubtargetInfo &STI,119raw_ostream &OS, bool IsBranch = false);120bool printAlias(const MCInst &MI, uint64_t Address,121const MCSubtargetInfo &STI, raw_ostream &OS);122void printSaveRestore(const MCInst *MI, const MCSubtargetInfo &STI,123raw_ostream &O);124void printRegisterList(const MCInst *MI, int opNum,125const MCSubtargetInfo &STI, raw_ostream &O);126};127} // end namespace llvm128129#endif130131132