LLVM API Documentation

MipsInstPrinter.h
Go to the documentation of this file.
00001 //=== MipsInstPrinter.h - Convert Mips MCInst to assembly syntax -*- C++ -*-==//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This class prints a Mips MCInst to a .s file.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_MIPS_INSTPRINTER_MIPSINSTPRINTER_H
00015 #define LLVM_LIB_TARGET_MIPS_INSTPRINTER_MIPSINSTPRINTER_H
00016 #include "llvm/MC/MCInstPrinter.h"
00017 
00018 namespace llvm {
00019 // These enumeration declarations were originally in MipsInstrInfo.h but
00020 // had to be moved here to avoid circular dependencies between
00021 // LLVMMipsCodeGen and LLVMMipsAsmPrinter.
00022 namespace Mips {
00023 // Mips Branch Codes
00024 enum FPBranchCode {
00025   BRANCH_F,
00026   BRANCH_T,
00027   BRANCH_FL,
00028   BRANCH_TL,
00029   BRANCH_INVALID
00030 };
00031 
00032 // Mips Condition Codes
00033 enum CondCode {
00034   // To be used with float branch True
00035   FCOND_F,
00036   FCOND_UN,
00037   FCOND_OEQ,
00038   FCOND_UEQ,
00039   FCOND_OLT,
00040   FCOND_ULT,
00041   FCOND_OLE,
00042   FCOND_ULE,
00043   FCOND_SF,
00044   FCOND_NGLE,
00045   FCOND_SEQ,
00046   FCOND_NGL,
00047   FCOND_LT,
00048   FCOND_NGE,
00049   FCOND_LE,
00050   FCOND_NGT,
00051 
00052   // To be used with float branch False
00053   // This conditions have the same mnemonic as the
00054   // above ones, but are used with a branch False;
00055   FCOND_T,
00056   FCOND_OR,
00057   FCOND_UNE,
00058   FCOND_ONE,
00059   FCOND_UGE,
00060   FCOND_OGE,
00061   FCOND_UGT,
00062   FCOND_OGT,
00063   FCOND_ST,
00064   FCOND_GLE,
00065   FCOND_SNE,
00066   FCOND_GL,
00067   FCOND_NLT,
00068   FCOND_GE,
00069   FCOND_NLE,
00070   FCOND_GT
00071 };
00072 
00073 const char *MipsFCCToString(Mips::CondCode CC);
00074 } // end namespace Mips
00075 
00076 class TargetMachine;
00077 
00078 class MipsInstPrinter : public MCInstPrinter {
00079 public:
00080   MipsInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
00081                   const MCRegisterInfo &MRI)
00082     : MCInstPrinter(MAI, MII, MRI) {}
00083 
00084   // Autogenerated by tblgen.
00085   void printInstruction(const MCInst *MI, raw_ostream &O);
00086   static const char *getRegisterName(unsigned RegNo);
00087 
00088   void printRegName(raw_ostream &OS, unsigned RegNo) const override;
00089   void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot) override;
00090 
00091   bool printAliasInstr(const MCInst *MI, raw_ostream &OS);
00092   void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
00093                                unsigned PrintMethodIdx, raw_ostream &O);
00094 
00095 private:
00096   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
00097   void printUnsignedImm(const MCInst *MI, int opNum, raw_ostream &O);
00098   void printUnsignedImm8(const MCInst *MI, int opNum, raw_ostream &O);
00099   void printMemOperand(const MCInst *MI, int opNum, raw_ostream &O);
00100   void printMemOperandEA(const MCInst *MI, int opNum, raw_ostream &O);
00101   void printFCCOperand(const MCInst *MI, int opNum, raw_ostream &O);
00102   void printSHFMask(const MCInst *MI, int opNum, raw_ostream &O);
00103 
00104   bool printAlias(const char *Str, const MCInst &MI, unsigned OpNo,
00105                   raw_ostream &OS);
00106   bool printAlias(const char *Str, const MCInst &MI, unsigned OpNo0,
00107                   unsigned OpNo1, raw_ostream &OS);
00108   bool printAlias(const MCInst &MI, raw_ostream &OS);
00109   void printSaveRestore(const MCInst *MI, raw_ostream &O);
00110 };
00111 } // end namespace llvm
00112 
00113 #endif