10b57cec5SDimitry Andric //=== MipsInstPrinter.h - Convert Mips MCInst to assembly syntax -*- C++ -*-==// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This class prints a Mips MCInst to a .s file. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSINSTPRINTER_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSINSTPRINTER_H 150b57cec5SDimitry Andric #include "llvm/MC/MCInstPrinter.h" 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric namespace llvm { 180b57cec5SDimitry Andric // These enumeration declarations were originally in MipsInstrInfo.h but 190b57cec5SDimitry Andric // had to be moved here to avoid circular dependencies between 200b57cec5SDimitry Andric // LLVMMipsCodeGen and LLVMMipsAsmPrinter. 210b57cec5SDimitry Andric namespace Mips { 220b57cec5SDimitry Andric // Mips Branch Codes 230b57cec5SDimitry Andric enum FPBranchCode { 240b57cec5SDimitry Andric BRANCH_F, 250b57cec5SDimitry Andric BRANCH_T, 260b57cec5SDimitry Andric BRANCH_FL, 270b57cec5SDimitry Andric BRANCH_TL, 280b57cec5SDimitry Andric BRANCH_INVALID 290b57cec5SDimitry Andric }; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric // Mips Condition Codes 320b57cec5SDimitry Andric enum CondCode { 330b57cec5SDimitry Andric // To be used with float branch True 340b57cec5SDimitry Andric FCOND_F, 350b57cec5SDimitry Andric FCOND_UN, 360b57cec5SDimitry Andric FCOND_OEQ, 370b57cec5SDimitry Andric FCOND_UEQ, 380b57cec5SDimitry Andric FCOND_OLT, 390b57cec5SDimitry Andric FCOND_ULT, 400b57cec5SDimitry Andric FCOND_OLE, 410b57cec5SDimitry Andric FCOND_ULE, 420b57cec5SDimitry Andric FCOND_SF, 430b57cec5SDimitry Andric FCOND_NGLE, 440b57cec5SDimitry Andric FCOND_SEQ, 450b57cec5SDimitry Andric FCOND_NGL, 460b57cec5SDimitry Andric FCOND_LT, 470b57cec5SDimitry Andric FCOND_NGE, 480b57cec5SDimitry Andric FCOND_LE, 490b57cec5SDimitry Andric FCOND_NGT, 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric // To be used with float branch False 520b57cec5SDimitry Andric // This conditions have the same mnemonic as the 530b57cec5SDimitry Andric // above ones, but are used with a branch False; 540b57cec5SDimitry Andric FCOND_T, 550b57cec5SDimitry Andric FCOND_OR, 560b57cec5SDimitry Andric FCOND_UNE, 570b57cec5SDimitry Andric FCOND_ONE, 580b57cec5SDimitry Andric FCOND_UGE, 590b57cec5SDimitry Andric FCOND_OGE, 600b57cec5SDimitry Andric FCOND_UGT, 610b57cec5SDimitry Andric FCOND_OGT, 620b57cec5SDimitry Andric FCOND_ST, 630b57cec5SDimitry Andric FCOND_GLE, 640b57cec5SDimitry Andric FCOND_SNE, 650b57cec5SDimitry Andric FCOND_GL, 660b57cec5SDimitry Andric FCOND_NLT, 670b57cec5SDimitry Andric FCOND_GE, 680b57cec5SDimitry Andric FCOND_NLE, 690b57cec5SDimitry Andric FCOND_GT 700b57cec5SDimitry Andric }; 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric const char *MipsFCCToString(Mips::CondCode CC); 730b57cec5SDimitry Andric } // end namespace Mips 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric class MipsInstPrinter : public MCInstPrinter { 760b57cec5SDimitry Andric public: MipsInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)770b57cec5SDimitry Andric MipsInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 780b57cec5SDimitry Andric const MCRegisterInfo &MRI) 790b57cec5SDimitry Andric : MCInstPrinter(MAI, MII, MRI) {} 800b57cec5SDimitry Andric 810b57cec5SDimitry Andric // Autogenerated by tblgen. 82e8d8bef9SDimitry Andric std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; 8381ad6265SDimitry Andric void printInstruction(const MCInst *MI, uint64_t Address, 8481ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 85*bdd1243dSDimitry Andric static const char *getRegisterName(MCRegister Reg); 860b57cec5SDimitry Andric 87*bdd1243dSDimitry Andric void printRegName(raw_ostream &OS, MCRegister Reg) const override; 88480093f4SDimitry Andric void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, 89480093f4SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O) override; 900b57cec5SDimitry Andric 9181ad6265SDimitry Andric bool printAliasInstr(const MCInst *MI, uint64_t Address, 9281ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &OS); 935ffd83dbSDimitry Andric void printCustomAliasOperand(const MCInst *MI, uint64_t Address, 945ffd83dbSDimitry Andric unsigned OpIdx, unsigned PrintMethodIdx, 9581ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric private: 9881ad6265SDimitry Andric void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 9981ad6265SDimitry Andric raw_ostream &O); 10081ad6265SDimitry Andric void printJumpOperand(const MCInst *MI, unsigned OpNo, 10181ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 10281ad6265SDimitry Andric void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo, 10381ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 1040b57cec5SDimitry Andric template <unsigned Bits, unsigned Offset = 0> 10581ad6265SDimitry Andric void printUImm(const MCInst *MI, int opNum, const MCSubtargetInfo &STI, 10681ad6265SDimitry Andric raw_ostream &O); 10781ad6265SDimitry Andric void printMemOperand(const MCInst *MI, int opNum, const MCSubtargetInfo &STI, 10881ad6265SDimitry Andric raw_ostream &O); 10981ad6265SDimitry Andric void printMemOperandEA(const MCInst *MI, int opNum, 11081ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 11181ad6265SDimitry Andric void printFCCOperand(const MCInst *MI, int opNum, const MCSubtargetInfo &STI, 11281ad6265SDimitry Andric raw_ostream &O); 1130b57cec5SDimitry Andric void printSHFMask(const MCInst *MI, int opNum, raw_ostream &O); 1140b57cec5SDimitry Andric 11581ad6265SDimitry Andric bool printAlias(const char *Str, const MCInst &MI, uint64_t Address, 11681ad6265SDimitry Andric unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &OS, 11781ad6265SDimitry Andric bool IsBranch = false); 11881ad6265SDimitry Andric bool printAlias(const char *Str, const MCInst &MI, uint64_t Address, 11981ad6265SDimitry Andric unsigned OpNo0, unsigned OpNo1, const MCSubtargetInfo &STI, 12081ad6265SDimitry Andric raw_ostream &OS, bool IsBranch = false); 12181ad6265SDimitry Andric bool printAlias(const MCInst &MI, uint64_t Address, 12281ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &OS); 12381ad6265SDimitry Andric void printSaveRestore(const MCInst *MI, const MCSubtargetInfo &STI, 12481ad6265SDimitry Andric raw_ostream &O); 12581ad6265SDimitry Andric void printRegisterList(const MCInst *MI, int opNum, 12681ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O); 1270b57cec5SDimitry Andric }; 1280b57cec5SDimitry Andric } // end namespace llvm 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andric #endif 131