mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-28 06:29:45 +00:00
per-function subtarget. Currently, code-gen passes the default or generic subtarget to the constructors of MCInstPrinter subclasses (see LLVMTargetMachine::addPassesToEmitFile), which enables some targets (AArch64, ARM, and X86) to change their instprinter's behavior based on the subtarget feature bits. Since the backend can now use different subtargets for each function, instprinter has to be changed to use the per-function subtarget rather than the default subtarget. This patch takes the first step towards enabling instprinter to change its behavior based on the per-function subtarget. It adds a bit "PassSubtarget" to AsmWriter which tells table-gen to pass a reference to MCSubtargetInfo to the various print methods table-gen auto-generates. I will follow up with changes to instprinters of AArch64, ARM, and X86. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233411 91177308-0d34-0410-b5e6-96231b3b80d8
117 lines
3.3 KiB
C++
117 lines
3.3 KiB
C++
//=== MipsInstPrinter.h - Convert Mips MCInst to assembly syntax -*- C++ -*-==//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This class prints a Mips MCInst to a .s file.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_TARGET_MIPS_INSTPRINTER_MIPSINSTPRINTER_H
|
|
#define LLVM_LIB_TARGET_MIPS_INSTPRINTER_MIPSINSTPRINTER_H
|
|
#include "llvm/MC/MCInstPrinter.h"
|
|
|
|
namespace llvm {
|
|
// These enumeration declarations were originally in MipsInstrInfo.h but
|
|
// had to be moved here to avoid circular dependencies between
|
|
// LLVMMipsCodeGen and LLVMMipsAsmPrinter.
|
|
namespace Mips {
|
|
// Mips Branch Codes
|
|
enum FPBranchCode {
|
|
BRANCH_F,
|
|
BRANCH_T,
|
|
BRANCH_FL,
|
|
BRANCH_TL,
|
|
BRANCH_INVALID
|
|
};
|
|
|
|
// Mips Condition Codes
|
|
enum CondCode {
|
|
// To be used with float branch True
|
|
FCOND_F,
|
|
FCOND_UN,
|
|
FCOND_OEQ,
|
|
FCOND_UEQ,
|
|
FCOND_OLT,
|
|
FCOND_ULT,
|
|
FCOND_OLE,
|
|
FCOND_ULE,
|
|
FCOND_SF,
|
|
FCOND_NGLE,
|
|
FCOND_SEQ,
|
|
FCOND_NGL,
|
|
FCOND_LT,
|
|
FCOND_NGE,
|
|
FCOND_LE,
|
|
FCOND_NGT,
|
|
|
|
// To be used with float branch False
|
|
// This conditions have the same mnemonic as the
|
|
// above ones, but are used with a branch False;
|
|
FCOND_T,
|
|
FCOND_OR,
|
|
FCOND_UNE,
|
|
FCOND_ONE,
|
|
FCOND_UGE,
|
|
FCOND_OGE,
|
|
FCOND_UGT,
|
|
FCOND_OGT,
|
|
FCOND_ST,
|
|
FCOND_GLE,
|
|
FCOND_SNE,
|
|
FCOND_GL,
|
|
FCOND_NLT,
|
|
FCOND_GE,
|
|
FCOND_NLE,
|
|
FCOND_GT
|
|
};
|
|
|
|
const char *MipsFCCToString(Mips::CondCode CC);
|
|
} // end namespace Mips
|
|
|
|
class TargetMachine;
|
|
|
|
class MipsInstPrinter : public MCInstPrinter {
|
|
public:
|
|
MipsInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
|
|
const MCRegisterInfo &MRI)
|
|
: MCInstPrinter(MAI, MII, MRI) {}
|
|
|
|
// Autogenerated by tblgen.
|
|
void printInstruction(const MCInst *MI, raw_ostream &O);
|
|
static const char *getRegisterName(unsigned RegNo);
|
|
|
|
void printRegName(raw_ostream &OS, unsigned RegNo) const override;
|
|
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
|
|
const MCSubtargetInfo &STI) override;
|
|
|
|
bool printAliasInstr(const MCInst *MI, raw_ostream &OS);
|
|
void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
|
|
unsigned PrintMethodIdx, raw_ostream &O);
|
|
|
|
private:
|
|
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printUnsignedImm(const MCInst *MI, int opNum, raw_ostream &O);
|
|
void printUnsignedImm8(const MCInst *MI, int opNum, raw_ostream &O);
|
|
void printMemOperand(const MCInst *MI, int opNum, raw_ostream &O);
|
|
void printMemOperandEA(const MCInst *MI, int opNum, raw_ostream &O);
|
|
void printFCCOperand(const MCInst *MI, int opNum, raw_ostream &O);
|
|
void printRegisterPair(const MCInst *MI, int opNum, raw_ostream &O);
|
|
void printSHFMask(const MCInst *MI, int opNum, raw_ostream &O);
|
|
|
|
bool printAlias(const char *Str, const MCInst &MI, unsigned OpNo,
|
|
raw_ostream &OS);
|
|
bool printAlias(const char *Str, const MCInst &MI, unsigned OpNo0,
|
|
unsigned OpNo1, raw_ostream &OS);
|
|
bool printAlias(const MCInst &MI, raw_ostream &OS);
|
|
void printSaveRestore(const MCInst *MI, raw_ostream &O);
|
|
void printRegisterList(const MCInst *MI, int opNum, raw_ostream &O);
|
|
};
|
|
} // end namespace llvm
|
|
|
|
#endif
|