#ifdef GEN_COMPRESS_INSTR
#undef GEN_COMPRESS_INSTR
static bool RISCVValidateMCOperandForCompress(const MCOperand &MCOp,
const MCSubtargetInfo &STI,
unsigned PredicateIndex) {
switch (PredicateIndex) {
default:
llvm_unreachable("Unknown MCOperandPredicate kind");
break;
case 1: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<8, 2>(Imm) && (Imm != 0);
}
case 2: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return (Imm != 0) && isInt<6>(Imm);
return MCOp.isBareSymbolRef();
}
case 3: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isInt<6>(Imm);
return MCOp.isBareSymbolRef();
}
case 4: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedInt<6, 4>(Imm) && (Imm != 0);
}
case 5: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isShiftedInt<8, 1>(Imm);
return MCOp.isBareSymbolRef();
}
case 6: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<5, 3>(Imm);
}
case 7: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<6, 3>(Imm);
}
case 8: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<5, 2>(Imm);
}
case 9: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<6, 2>(Imm);
}
case 10: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isShiftedInt<11, 1>(Imm);
return MCOp.isBareSymbolRef();
}
case 11: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isUInt<2>(Imm);
}
case 12: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isUInt<5>(Imm);
}
case 13: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isUInt<4>(Imm);
}
case 14: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<1, 1>(Imm);
}
case 15: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<5, 1>(Imm);
}
case 16: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
return isShiftedUInt<4, 1>(Imm);
}
case 17: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return (Imm != 0) && (isUInt<5>(Imm) ||
(Imm >= 0xfffe0 && Imm <= 0xfffff));
return MCOp.isBareSymbolRef();
}
case 18: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
if (STI.getTargetTriple().isArch64Bit())
return isUInt<6>(Imm) && (Imm != 0);
return isUInt<5>(Imm) && (Imm != 0);
}
}
}
static bool compressInst(MCInst &OutInst,
const MCInst &MI,
const MCSubtargetInfo &STI) {
switch (MI.getOpcode()) {
default: return false;
case RISCV::ADD: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_MV);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isReg()) &&
(MI.getOperand(2).getReg() == RISCV::X0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_MV);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_ADD);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(2).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(2).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_ADD);
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ADDI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::C_ADDI4SPN);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X0) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X0) &&
(MI.getOperand(2).isImm()) &&
(MI.getOperand(2).getImm() == 0)) {
OutInst.setOpcode(RISCV::C_NOP);
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 2)) {
OutInst.setOpcode(RISCV::C_ADDI);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 3)) {
OutInst.setOpcode(RISCV::C_LI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X2) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X2) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 4)) {
OutInst.setOpcode(RISCV::C_ADDI16SP);
OutInst.addOperand(MCOperand::createReg(RISCV::X2));
OutInst.addOperand(MCOperand::createReg(RISCV::X2));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isImm()) &&
(MI.getOperand(2).getImm() == 0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_MV);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ADDIW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 3)) {
OutInst.setOpcode(RISCV::C_ADDIW);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 3)) {
OutInst.setOpcode(RISCV::C_LI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ADDW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_ADDW);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(2).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_ADDW);
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ADD_UW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZba] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(MI.getOperand(2).getReg() == RISCV::X0) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_ZEXT_W);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::AND: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_AND);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(2).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_AND);
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ANDI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 3)) {
OutInst.setOpcode(RISCV::C_ANDI);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isImm()) &&
(MI.getOperand(2).getImm() == 255) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_ZEXT_B);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::BEQ: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::C_BEQZ);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X0) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::C_BEQZ);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::BNE: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X0) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::C_BNEZ);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X0) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::C_BNEZ);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::EBREAK: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca])) {
OutInst.setOpcode(RISCV::C_EBREAK);
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::FLD: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64CRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 6)) {
OutInst.setOpcode(RISCV::C_FLD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 7)) {
OutInst.setOpcode(RISCV::C_FLDSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::FLW: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32CRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 8)) {
OutInst.setOpcode(RISCV::C_FLW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 9)) {
OutInst.setOpcode(RISCV::C_FLWSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::FSD: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64CRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 6)) {
OutInst.setOpcode(RISCV::C_FSD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 7)) {
OutInst.setOpcode(RISCV::C_FSDSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::FSW: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32CRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 8)) {
OutInst.setOpcode(RISCV::C_FSW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 9)) {
OutInst.setOpcode(RISCV::C_FSWSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::JAL: {
if (!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X1) &&
RISCVValidateMCOperandForCompress(MI.getOperand(1), STI, 10)) {
OutInst.setOpcode(RISCV::C_JAL);
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X0) &&
RISCVValidateMCOperandForCompress(MI.getOperand(1), STI, 10)) {
OutInst.setOpcode(RISCV::C_J);
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::JALR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X0) &&
(MI.getOperand(2).isImm()) &&
(MI.getOperand(2).getImm() == 0) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_JR);
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X1) &&
(MI.getOperand(2).isImm()) &&
(MI.getOperand(2).getImm() == 0) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_JALR);
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::LBU: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 11)) {
OutInst.setOpcode(RISCV::C_LBU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 12)) {
OutInst.setOpcode(RISCV::QK_C_LBU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 13)) {
OutInst.setOpcode(RISCV::QK_C_LBUSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::LD: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 6)) {
OutInst.setOpcode(RISCV::C_LD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 7)) {
OutInst.setOpcode(RISCV::C_LDSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::LH: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 14)) {
OutInst.setOpcode(RISCV::C_LH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::LHU: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 14)) {
OutInst.setOpcode(RISCV::C_LHU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 15)) {
OutInst.setOpcode(RISCV::QK_C_LHU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 16)) {
OutInst.setOpcode(RISCV::QK_C_LHUSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::LUI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0X2RegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(1), STI, 17)) {
OutInst.setOpcode(RISCV::C_LUI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::LW: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 8)) {
OutInst.setOpcode(RISCV::C_LW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 9)) {
OutInst.setOpcode(RISCV::C_LWSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::MUL: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZmmul] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_MUL);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZmmul] &&
(MI.getOperand(2).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(2).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_MUL);
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::OR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_OR);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(2).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_OR);
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SB: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 11)) {
OutInst.setOpcode(RISCV::C_SB);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 12)) {
OutInst.setOpcode(RISCV::QK_C_SB);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 13)) {
OutInst.setOpcode(RISCV::QK_C_SBSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SD: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 6)) {
OutInst.setOpcode(RISCV::C_SD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 7)) {
OutInst.setOpcode(RISCV::C_SDSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SEXT_B: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_SEXT_B);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SEXT_H: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_SEXT_H);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SH: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 14)) {
OutInst.setOpcode(RISCV::C_SH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 15)) {
OutInst.setOpcode(RISCV::QK_C_SH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 16)) {
OutInst.setOpcode(RISCV::QK_C_SHSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SLLI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRNoX0RegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 18)) {
OutInst.setOpcode(RISCV::C_SLLI);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SRAI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 18)) {
OutInst.setOpcode(RISCV::C_SRAI);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SRLI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 18)) {
OutInst.setOpcode(RISCV::C_SRLI);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SSPOPCHK: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcmop] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZicfiss] &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X5)) {
OutInst.setOpcode(RISCV::C_SSPOPCHK);
OutInst.addOperand(MCOperand::createReg(RISCV::X5));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SSPUSH: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcmop] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZicfiss] &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X1)) {
OutInst.setOpcode(RISCV::C_SSPUSH);
OutInst.addOperand(MCOperand::createReg(RISCV::X1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SUB: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_SUB);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SUBW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_SUBW);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::SW: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 8)) {
OutInst.setOpcode(RISCV::C_SW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::SPRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForCompress(MI.getOperand(2), STI, 9)) {
OutInst.setOpcode(RISCV::C_SWSP);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::UNIMP: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca])) {
OutInst.setOpcode(RISCV::C_UNIMP);
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::XOR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::C_XOR);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(2).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(2).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(2).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_XOR);
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(2));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::XORI: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(2).isImm()) &&
(MI.getOperand(2).getImm() == -1) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_NOT);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ZEXT_H_RV32: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_ZEXT_H);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::ZEXT_H_RV64: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(1).isReg()) && (MI.getOperand(0).isReg()) &&
(MI.getOperand(1).getReg() == MI.getOperand(0).getReg()) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRCRegClassID].contains(MI.getOperand(1).getReg()))) {
OutInst.setOpcode(RISCV::C_ZEXT_H);
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
}
}
return false;
}
#endif
#ifdef GEN_UNCOMPRESS_INSTR
#undef GEN_UNCOMPRESS_INSTR
static bool RISCVValidateMCOperandForUncompress(const MCOperand &MCOp,
const MCSubtargetInfo &STI,
unsigned PredicateIndex) {
switch (PredicateIndex) {
default:
llvm_unreachable("Unknown MCOperandPredicate kind");
break;
case 1: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isInt<12>(Imm);
return MCOp.isBareSymbolRef();
}
case 2: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isShiftedInt<12, 1>(Imm);
return MCOp.isBareSymbolRef();
}
case 3: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isShiftedInt<20, 1>(Imm);
return MCOp.isBareSymbolRef();
}
case 4: {
int64_t Imm;
if (MCOp.evaluateAsConstantImm(Imm))
return isUInt<20>(Imm);
return MCOp.isBareSymbolRef();
}
case 5: {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
if (STI.getTargetTriple().isArch64Bit())
return isUInt<6>(Imm);
return isUInt<5>(Imm);
}
}
}
static bool uncompressInst(MCInst &OutInst,
const MCInst &MI,
const MCSubtargetInfo &STI) {
switch (MI.getOpcode()) {
default: return false;
case RISCV::C_ADD: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::ADD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ADDI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::ADDI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ADDI16SP: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X2) &&
(MI.getOperand(1).isReg()) &&
(MI.getOperand(1).getReg() == RISCV::X2) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::ADDI);
OutInst.addOperand(MCOperand::createReg(RISCV::X2));
OutInst.addOperand(MCOperand::createReg(RISCV::X2));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ADDI4SPN: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::ADDI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ADDIW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::ADDIW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ADDW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::ADDW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_AND: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::AND);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ANDI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::ANDI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_BEQZ: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(1), STI, 2)) {
OutInst.setOpcode(RISCV::BEQ);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_BNEZ: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(1), STI, 2)) {
OutInst.setOpcode(RISCV::BNE);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_EBREAK: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca])) {
OutInst.setOpcode(RISCV::EBREAK);
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FLD: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FLD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FLDSP: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FLD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FLW: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FLW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FLWSP: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FLW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FSD: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FSD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FSDSP: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtD] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZcd]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FSD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FSW: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FSW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_FSWSP: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtF] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZce] || STI.getFeatureBits()[RISCV::FeatureStdExtZcf]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::FPR32RegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::FSW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_J: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(0), STI, 3)) {
OutInst.setOpcode(RISCV::JAL);
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MI.getOperand(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_JAL: {
if (!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(0), STI, 3)) {
OutInst.setOpcode(RISCV::JAL);
OutInst.addOperand(MCOperand::createReg(RISCV::X1));
OutInst.addOperand(MI.getOperand(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_JALR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MCOperand::createImm(0), STI, 1)) {
OutInst.setOpcode(RISCV::JALR);
OutInst.addOperand(MCOperand::createReg(RISCV::X1));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createImm(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_JR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MCOperand::createImm(0), STI, 1)) {
OutInst.setOpcode(RISCV::JALR);
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createImm(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LBU: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LBU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LD: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LDSP: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LH: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LHU: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LHU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(1), STI, 1)) {
OutInst.setOpcode(RISCV::ADDI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LUI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(1), STI, 4)) {
OutInst.setOpcode(RISCV::LUI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LW: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_LWSP: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_MUL: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZmmul] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::MUL);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_MV: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MCOperand::createImm(0), STI, 1)) {
OutInst.setOpcode(RISCV::ADDI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MCOperand::createImm(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_NOP: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
RISCVValidateMCOperandForUncompress(MCOperand::createImm(0), STI, 1)) {
OutInst.setOpcode(RISCV::ADDI);
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.addOperand(MCOperand::createImm(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_NOT: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MCOperand::createImm(-1), STI, 1)) {
OutInst.setOpcode(RISCV::XORI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createImm(-1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_OR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::OR);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SB: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SB);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SD: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SDSP: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SD);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SEXT_B: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg()))) {
OutInst.setOpcode(RISCV::SEXT_B);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SEXT_H: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg()))) {
OutInst.setOpcode(RISCV::SEXT_H);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SH: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SLLI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::SLLI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SRAI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::SRAI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SRLI: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 5)) {
OutInst.setOpcode(RISCV::SRLI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SSPOPCHK: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcmop] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZicfiss] &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X5)) {
OutInst.setOpcode(RISCV::SSPOPCHK);
OutInst.addOperand(MCOperand::createReg(RISCV::X5));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SSPUSH: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcmop] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZicfiss] &&
(MI.getOperand(0).isReg()) &&
(MI.getOperand(0).getReg() == RISCV::X1)) {
OutInst.setOpcode(RISCV::SSPUSH);
OutInst.addOperand(MCOperand::createReg(RISCV::X1));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SUB: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::SUB);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SUBW: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
(STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::SUBW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SW: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_SWSP: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_UNIMP: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca])) {
OutInst.setOpcode(RISCV::UNIMP);
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_XOR: {
if ((STI.getFeatureBits()[RISCV::FeatureStdExtC] || STI.getFeatureBits()[RISCV::FeatureStdExtZca]) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(2).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(2).getReg()))) {
OutInst.setOpcode(RISCV::XOR);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ZEXT_B: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
RISCVValidateMCOperandForUncompress(MCOperand::createImm(255), STI, 1)) {
OutInst.setOpcode(RISCV::ANDI);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createImm(255));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ZEXT_H: {
if (STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
!STI.getFeatureBits()[RISCV::Feature64Bit] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg()))) {
OutInst.setOpcode(RISCV::ZEXT_H_RV32);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.setLoc(MI.getLoc());
return true;
}
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZbb] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg()))) {
OutInst.setOpcode(RISCV::ZEXT_H_RV64);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::C_ZEXT_W: {
if (STI.getFeatureBits()[RISCV::Feature64Bit] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZba] &&
STI.getFeatureBits()[RISCV::FeatureStdExtZcb] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg()))) {
OutInst.setOpcode(RISCV::ADD_UW);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MCOperand::createReg(RISCV::X0));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_LBU: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LBU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_LBUSP: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LBU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_LHU: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LHU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_LHUSP: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::LHU);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_SB: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SB);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_SBSP: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SB);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_SH: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
break;
}
case RISCV::QK_C_SHSP: {
if (STI.getFeatureBits()[RISCV::FeatureVendorXwchc] &&
(MI.getOperand(0).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(0).getReg())) &&
(MI.getOperand(1).isReg()) &&
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(MI.getOperand(1).getReg())) &&
RISCVValidateMCOperandForUncompress(MI.getOperand(2), STI, 1)) {
OutInst.setOpcode(RISCV::SH);
OutInst.addOperand(MI.getOperand(0));
OutInst.addOperand(MI.getOperand(1));
OutInst.addOperand(MI.getOperand(2));
OutInst.setLoc(MI.getLoc());
return true;
}
}
}
return false;
}
#endif
#ifdef GEN_CHECK_COMPRESS_INSTR
#undef GEN_CHECK_COMPRESS_INSTR
static bool RISCVValidateMachineOperand(const MachineOperand &MO,
const RISCVSubtarget *Subtarget,
unsigned PredicateIndex) { … }
static bool isCompressibleInst(const MachineInstr &MI,
const RISCVSubtarget &STI) { … }
#endif