26#define DEBUG_TYPE "asm-printer"
29#define PRINT_ALIAS_INSTR
30#include "RISCVGenAsmWriter.inc"
42 CLOpts(
RISCV_MC::getCLOpts(
MAI.getTargetOptions())) {}
50 if (Opt ==
"no-aliases") {
54 if (Opt ==
"numeric") {
58 if (Opt ==
"emit-x8-as-fp") {
76 NewMI = &UncompressedMI;
102 assert(MO.
isExpr() &&
"Unknown operand kind in printOperand");
131 unsigned Imm =
MI->getOperand(OpNo).getImm();
132 auto Range = RISCVSysReg::lookupSysRegByEncoding(
Imm);
134 return !Reg.IsAltName && !Reg.IsDeprecatedName &&
135 Reg.FeaturesRequired.any() &&
138 for (
auto &Reg :
Range) {
139 if (Reg.IsAltName || Reg.IsDeprecatedName)
142 (!PreferFeatureSpecific || Reg.FeaturesRequired.any())) {
153 unsigned FenceArg =
MI->getOperand(OpNo).getImm();
154 assert (((FenceArg >> 4) == 0) &&
"Invalid immediate in printFenceArg");
174 "SpacemiT's Integer Matrix only supports [i4|i8] mode");
204 unsigned Imm =
MI->getOperand(OpNo).getImm();
207 }
else if (
Imm == 30) {
209 }
else if (
Imm == 31) {
217 if (FPVal == (
int)(FPVal))
229 assert(MO.
isReg() &&
"printZeroOffsetMemOp can only print register operands");
237 unsigned Imm =
MI->getOperand(OpNo).getImm();
251 unsigned Imm =
MI->getOperand(OpNo).getImm();
267 unsigned Imm =
MI->getOperand(OpNo).getImm();
309 const MCOperand &OffsetMO =
MI->getOperand(OpNo + 1);
311 assert(OffsetMO.
isReg() &&
"printRegReg can only print register operands");
316 assert(BaseMO.
isReg() &&
"printRegReg can only print register operands");
324 int64_t
Imm =
MI->getOperand(OpNo).getImm();
325 bool IsRV64 = STI.
hasFeature(RISCV::Feature64Bit);
326 int64_t StackAdj = 0;
327 auto RlistVal =
MI->getOperand(0).getImm();
331 "Incorrect stack adjust");
333 StackAdj = -StackAdj;
345 assert(MO.
isReg() &&
"printVMaskReg can only print register operands");
346 if (MO.
getReg() == RISCV::NoRegister)
358 assert(MO.
isReg() &&
"printVScaleReg can only print register operands");
369 assert(MO.
isImm() &&
"printTileLambda can only print immediate operands");
370 unsigned Lambda = MO.
getImm();
374 assert(Lambda <= 7 &&
"Unexpected tile lambda encoding");
375 O <<
", L" << (1U << (Lambda - 1));
381 const unsigned Opcode =
MI->getOpcode();
382 uint64_t
Imm =
Op.getImm();
384 (Opcode == RISCV::ANDI || Opcode == RISCV::ORI || Opcode == RISCV::XORI ||
385 Opcode == RISCV::C_ANDI || Opcode == RISCV::AUIPC ||
386 Opcode == RISCV::LUI)) {
404 : RISCV::ABIRegAltName);
static SDValue Widen(SelectionDAG *CurDAG, SDValue N)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > ArchRegNames("csky-arch-reg-names", cl::desc("Print architectural register names rather than the " "ABI names (such as r14 instead of sp)"), cl::init(false), cl::Hidden)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This class is intended to be used as a base class for asm properties and features specific to the tar...
WithMarkup markup(raw_ostream &OS, Markup M)
format_object< int64_t > formatHex(int64_t Value) const
bool SymbolizeOperands
If true, symbolize branch target and memory reference operands.
const MCRegisterInfo & MRI
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
bool PrintBranchImmAsAddress
If true, a branch immediate (e.g.
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii, const MCRegisterInfo &mri)
bool PrintAliases
True if we prefer aliases (e.g. nop) to raw mnemonics.
Instances of this class represent a single low-level machine instruction.
Interface to description of machine instruction set.
Instances of this class represent operands of the MCInst class.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
const FeatureBitset & getFeatureBits() const
void printSMTVType(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegList(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printTileLambda(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printCSRSystemRegister(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printXSfmmVType(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printImm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printFenceArg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printVMaskReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
bool applyTargetSpecificCLOption(StringRef Opt) override
Customize the printer according to a command line option.
void printFRMArgLegacy(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
bool printAliasInstr(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printFRMArg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
void printFPImmOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O)
void printZeroOffsetMemOp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printRegName(raw_ostream &O, MCRegister Reg) override
Print the assembler register name.
void printVTypeI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printVScaleReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
void printStackAdj(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O, bool Negate=false)
void printBranchOperand(const MCInst *MI, uint64_t Address, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
static const char * getRegisterName(const RISCVMCOptions &CLOpts, MCRegister Reg)
RISCVInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Represent a constant reference to a string, i.e.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
This class implements an extremely fast bulk output stream that can only output to a stream.
static StringRef roundingModeToString(RoundingMode RndMode)
float getFPImm(unsigned Imm)
bool uncompress(MCInst &OutInst, const MCInst &MI, const MCSubtargetInfo &STI)
static unsigned getXSfmmWiden(unsigned VType)
static bool isValidVType(unsigned VType)
LLVM_ABI void printVType(unsigned VType, raw_ostream &OS)
static bool isValidXSfmmVType(unsigned VTypeI)
static bool isAltFmt(unsigned VType)
static unsigned getSEW(unsigned VType)
static unsigned getStackAdjBase(unsigned RlistVal, bool IsRV64)
static StringRef SMTVTypeModeToString(SMTVTypeMode TypeMode)
static bool isValidSMTVTypeMode(unsigned Mode)
This is an optimization pass for GlobalISel generic memory operations.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
DWARFExpression::Operation Op