[llvm] [Mips] Add named COP0 registers (PR #229391)
Jiaxun Yang via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 05:12:56 PDT 2026
https://github.com/FlyGoat created https://github.com/llvm/llvm-project/pull/229391
Accept COP0 names such as $config1 alongside $16, 1. A numeric register with no selector selects SEL=0.
Define one physical register for each REG/SEL pair and pack the pair into HWEncoding. Instructions use one COP0 machine operand and extract REG and SEL into separate encoding fields. Update encoding, decoding, printing, interrupt lowering, and register-usage masks to use this representation.
Convert MFTC0/MTTC0 aliases to MFTR/MTTR during assembly matching. Check selector availability in the COP0 parser.
>From 3639b5bc1a2d4c43654affeea00c94c29fe47049 Mon Sep 17 00:00:00 2001
From: Jiaxun Yang <jiaxun.yang at flygoat.com>
Date: Tue, 6 Oct 2026 13:02:07 +0100
Subject: [PATCH] [Mips] Add named COP0 registers
Accept COP0 names such as $config1 alongside $16, 1. A numeric register with no selector selects SEL=0.
Define one physical register for each REG/SEL pair and pack the pair into HWEncoding. Instructions use one COP0 machine operand and extract REG and SEL into separate encoding fields. Update encoding, decoding, printing, interrupt lowering, and register-usage masks to use this representation.
Convert MFTC0/MTTC0 aliases to MFTR/MTTR during assembly matching. Check selector availability in the COP0 parser.
---
.../Target/Mips/AsmParser/MipsAsmParser.cpp | 160 ++++++++++++------
.../Mips/Disassembler/MipsDisassembler.cpp | 5 +-
.../Mips/MCTargetDesc/MipsInstPrinter.cpp | 10 ++
.../Mips/MCTargetDesc/MipsInstPrinter.h | 2 +
.../Mips/MCTargetDesc/MipsMCTargetDesc.cpp | 8 +
.../Mips/MCTargetDesc/MipsMCTargetDesc.h | 8 +
.../Mips/MCTargetDesc/MipsOptionRecord.cpp | 6 +-
.../Target/Mips/MicroMips32r6InstrFormats.td | 5 +-
.../lib/Target/Mips/MicroMips32r6InstrInfo.td | 22 +--
llvm/lib/Target/Mips/MicroMipsInstrFormats.td | 10 +-
llvm/lib/Target/Mips/MicroMipsInstrInfo.td | 30 +---
llvm/lib/Target/Mips/Mips64InstrInfo.td | 28 +--
llvm/lib/Target/Mips/MipsInstrFormats.td | 7 +
llvm/lib/Target/Mips/MipsInstrInfo.td | 52 +++---
llvm/lib/Target/Mips/MipsMTInstrInfo.td | 24 ++-
llvm/lib/Target/Mips/MipsRegisterInfo.td | 70 +++++++-
llvm/lib/Target/Mips/MipsSEFrameLowering.cpp | 10 +-
llvm/test/CodeGen/Mips/cop0-registers.mir | 26 +++
llvm/test/MC/Mips/cop0-register-invalid.s | 11 ++
llvm/test/MC/Mips/cop0-register-isa.s | 17 ++
llvm/test/MC/Mips/cop0-register-names.s | 26 +++
llvm/test/MC/Mips/mips-cop0-reginfo.s | 2 +-
llvm/test/MC/Mips/mt/mftr-mttr-aliases.s | 3 +
llvm/test/MC/Mips/virt/invalid.s | 8 +-
llvm/test/MC/Mips/virt/invalid64.s | 4 +-
25 files changed, 368 insertions(+), 186 deletions(-)
create mode 100644 llvm/test/CodeGen/Mips/cop0-registers.mir
create mode 100644 llvm/test/MC/Mips/cop0-register-invalid.s
create mode 100644 llvm/test/MC/Mips/cop0-register-isa.s
create mode 100644 llvm/test/MC/Mips/cop0-register-names.s
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index d2ef7003721e1e9..e0280efb72716d4 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -167,6 +167,15 @@ class MipsAsmParser : public MCTargetAsmParser {
SMRange Range, bool ShowColors = true);
void ConvertXWPOperands(MCInst &Inst, const OperandVector &Operands);
+ template <unsigned Opcode, bool IsMFTR>
+ void ConvertMTTransferCOP0Operands(MCInst &Inst,
+ const OperandVector &Operands);
+ void ConvertMFTC0Operands(MCInst &Inst, const OperandVector &Operands) {
+ ConvertMTTransferCOP0Operands<Mips::MFTR, true>(Inst, Operands);
+ }
+ void ConvertMTTC0Operands(MCInst &Inst, const OperandVector &Operands) {
+ ConvertMTTransferCOP0Operands<Mips::MTTR, false>(Inst, Operands);
+ }
#define GET_ASSEMBLER_HEADER
#include "MipsGenAsmMatcher.inc"
@@ -204,6 +213,7 @@ class MipsAsmParser : public MCTargetAsmParser {
const AsmToken &Token, SMLoc S);
ParseStatus matchAnyRegisterWithoutDollar(OperandVector &Operands, SMLoc S);
ParseStatus parseAnyRegister(OperandVector &Operands);
+ ParseStatus parseCOP0Register(OperandVector &Operands);
ParseStatus parseJumpTarget(OperandVector &Operands);
ParseStatus parseInvNum(OperandVector &Operands);
ParseStatus parseRegisterList(OperandVector &Operands);
@@ -941,9 +951,7 @@ class MipsOperand : public MCParsedAsmOperand {
/// Coerce the register to COP0 and return the real register for the
/// current target.
MCRegister getCOP0Reg() const {
- assert(isRegIdx() && (RegIdx.Kind & RegKind_COP0) && "Invalid access!");
- unsigned ClassID = Mips::COP0RegClassID;
- return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
+ return MIPS_MC::getCOP0Register(*RegIdx.RegInfo, getCOP0Encoding());
}
/// Coerce the register to COP2 and return the real register for the
@@ -1242,6 +1250,16 @@ class MipsOperand : public MCParsedAsmOperand {
}
bool isRegIdx() const { return Kind == k_RegisterIndex; }
+
+ bool isNumericReg() const {
+ return isRegIdx() && RegIdx.Kind == RegKind_Numeric && RegIdx.Index < 32;
+ }
+
+ unsigned getNumericRegIndex() const {
+ assert(isNumericReg() && "Invalid numeric register");
+ return RegIdx.Index;
+ }
+
bool isImm() const override { return Kind == k_Immediate; }
bool isConstantImm() const {
@@ -1493,6 +1511,14 @@ class MipsOperand : public MCParsedAsmOperand {
return CreateReg(Index, Str, RegKind_FGR, RegInfo, S, E, Parser);
}
+ static std::unique_ptr<MipsOperand>
+ createCOP0Reg(unsigned Encoding, StringRef Str, const MCRegisterInfo *RegInfo,
+ SMLoc S, SMLoc E, MipsAsmParser &Parser) {
+ assert(MIPS_MC::getCOP0RegNum(Encoding) < 32 &&
+ MIPS_MC::getCOP0Sel(Encoding) < 8 && "Invalid COP0 register encoding");
+ return CreateReg(Encoding, Str, RegKind_COP0, RegInfo, S, E, Parser);
+ }
+
/// Create a register that is definitely a HWReg.
/// This is typically only used for named registers such as $hwr_cpunum.
static std::unique_ptr<MipsOperand>
@@ -1643,7 +1669,12 @@ class MipsOperand : public MCParsedAsmOperand {
}
bool isCOP0AsmReg() const {
- return isRegIdx() && RegIdx.Kind & RegKind_COP0 && RegIdx.Index <= 31;
+ return isRegIdx() && RegIdx.Kind == RegKind_COP0;
+ }
+
+ unsigned getCOP0Encoding() const {
+ assert(isCOP0AsmReg() && "Invalid COP0 register");
+ return RegIdx.Index;
}
bool isCOP2AsmReg() const {
@@ -2644,7 +2675,6 @@ MipsAsmParser::tryExpandInstruction(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
return expandSne(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
case Mips::SNEIMacro:
return expandSneI(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
- case Mips::MFTC0: case Mips::MTTC0:
case Mips::MFTGPR: case Mips::MTTGPR:
case Mips::MFTLO: case Mips::MTTLO:
case Mips::MFTHI: case Mips::MTTHI:
@@ -5602,64 +5632,16 @@ static unsigned getRegisterForMxtrFP(MCInst &Inst, bool IsMFTC1) {
}
}
-// Map the coprocessor operand the corresponding gpr register operand.
-static unsigned getRegisterForMxtrC0(MCInst &Inst, bool IsMFTC0) {
- switch (Inst.getOperand(IsMFTC0 ? 1 : 0).getReg().id()) {
- case Mips::COP00: return Mips::ZERO;
- case Mips::COP01: return Mips::AT;
- case Mips::COP02: return Mips::V0;
- case Mips::COP03: return Mips::V1;
- case Mips::COP04: return Mips::A0;
- case Mips::COP05: return Mips::A1;
- case Mips::COP06: return Mips::A2;
- case Mips::COP07: return Mips::A3;
- case Mips::COP08: return Mips::T0;
- case Mips::COP09: return Mips::T1;
- case Mips::COP010: return Mips::T2;
- case Mips::COP011: return Mips::T3;
- case Mips::COP012: return Mips::T4;
- case Mips::COP013: return Mips::T5;
- case Mips::COP014: return Mips::T6;
- case Mips::COP015: return Mips::T7;
- case Mips::COP016: return Mips::S0;
- case Mips::COP017: return Mips::S1;
- case Mips::COP018: return Mips::S2;
- case Mips::COP019: return Mips::S3;
- case Mips::COP020: return Mips::S4;
- case Mips::COP021: return Mips::S5;
- case Mips::COP022: return Mips::S6;
- case Mips::COP023: return Mips::S7;
- case Mips::COP024: return Mips::T8;
- case Mips::COP025: return Mips::T9;
- case Mips::COP026: return Mips::K0;
- case Mips::COP027: return Mips::K1;
- case Mips::COP028: return Mips::GP;
- case Mips::COP029: return Mips::SP;
- case Mips::COP030: return Mips::FP;
- case Mips::COP031: return Mips::RA;
- default: llvm_unreachable("Unknown register for mttc0 alias!");
- }
-}
-
/// Expand an alias of 'mftr' or 'mttr' into the full instruction, by producing
/// an mftr or mttr with the correctly mapped gpr register, u, sel and h bits.
bool MipsAsmParser::expandMXTRAlias(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) {
MipsTargetStreamer &TOut = getTargetStreamer();
MCRegister rd;
- unsigned u = 1;
unsigned sel = 0;
unsigned h = 0;
bool IsMFTR = false;
switch (Inst.getOpcode()) {
- case Mips::MFTC0:
- IsMFTR = true;
- [[fallthrough]];
- case Mips::MTTC0:
- u = 0;
- rd = getRegisterForMxtrC0(Inst, IsMFTR);
- sel = Inst.getOperand(2).getImm();
- break;
case Mips::MFTGPR:
IsMFTR = true;
[[fallthrough]];
@@ -5708,7 +5690,7 @@ bool MipsAsmParser::expandMXTRAlias(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
: (Inst.getOpcode() != Mips::MTTDSP ? Inst.getOperand(1).getReg()
: Inst.getOperand(0).getReg());
- TOut.emitRRIII(IsMFTR ? Mips::MFTR : Mips::MTTR, Op0, Op1, u, sel, h, IDLoc,
+ TOut.emitRRIII(IsMFTR ? Mips::MFTR : Mips::MTTR, Op0, Op1, 1, sel, h, IDLoc,
STI);
return false;
}
@@ -5789,8 +5771,6 @@ unsigned MipsAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
if (Inst.getOperand(0).getImm() != 0 && !hasMips32())
return Match_NonZeroOperandForSync;
return Match_Success;
- case Mips::MFC0:
- case Mips::MTC0:
case Mips::MTC2:
case Mips::MFC2:
if (Inst.getOperand(2).getImm() != 0 && !hasMips32())
@@ -6139,6 +6119,25 @@ void MipsAsmParser::ConvertXWPOperands(MCInst &Inst,
((MipsOperand &)*Operands[2]).addMemOperands(Inst, 2);
}
+template <unsigned Opcode, bool IsMFTR>
+void MipsAsmParser::ConvertMTTransferCOP0Operands(
+ MCInst &Inst, const OperandVector &Operands) {
+ MCRegister GPR = static_cast<const MipsOperand &>(*Operands[1]).getGPR32Reg();
+ unsigned Encoding =
+ static_cast<const MipsOperand &>(*Operands[2]).getCOP0Encoding();
+ // MFTR/MTTR use a GPR-number operand for the selected register bank.
+ MCRegister Reg = getContext()
+ .getRegisterInfo()
+ ->getRegClass(Mips::GPR32RegClassID)
+ .getRegister(MIPS_MC::getCOP0RegNum(Encoding));
+ Inst.setOpcode(Opcode);
+ Inst.addOperand(MCOperand::createReg(IsMFTR ? GPR : Reg));
+ Inst.addOperand(MCOperand::createReg(IsMFTR ? Reg : GPR));
+ Inst.addOperand(MCOperand::createImm(0)); // u: COP0 register bank.
+ Inst.addOperand(MCOperand::createImm(MIPS_MC::getCOP0Sel(Encoding)));
+ Inst.addOperand(MCOperand::createImm(0)); // h: low half.
+}
+
void
MipsAsmParser::printWarningWithFixIt(const Twine &Msg, const Twine &FixMsg,
SMRange Range, bool ShowColors) {
@@ -6593,6 +6592,15 @@ ParseStatus MipsAsmParser::matchAnyRegisterNameWithoutDollar(
return ParseStatus::Success;
}
+ const MCRegisterInfo &MRI = *getContext().getRegisterInfo();
+ if (MCRegister Reg = MIPS_MC::matchRegisterName(
+ Identifier, MRI, Mips::COP0RegClassID, Mips::RegAliasName)) {
+ Operands.push_back(MipsOperand::createCOP0Reg(
+ MRI.getEncodingValue(Reg), Identifier, &MRI, S, getLexer().getLoc(),
+ *this));
+ return ParseStatus::Success;
+ }
+
Index = matchFPURegisterName(Identifier);
if (Index != -1) {
Operands.push_back(MipsOperand::createFGRReg(
@@ -6670,6 +6678,46 @@ MipsAsmParser::matchAnyRegisterWithoutDollar(OperandVector &Operands, SMLoc S) {
return matchAnyRegisterWithoutDollar(Operands, Token, S);
}
+ParseStatus MipsAsmParser::parseCOP0Register(OperandVector &Operands) {
+ SMLoc S = getLexer().getLoc();
+ SmallVector<std::unique_ptr<MCParsedAsmOperand>, 1> RegOperands;
+ ParseStatus Res = parseAnyRegister(RegOperands);
+ if (!Res.isSuccess())
+ return Res;
+ const auto &Op = static_cast<const MipsOperand &>(*RegOperands.back());
+ unsigned Encoding;
+ if (Op.isCOP0AsmReg())
+ Encoding = Op.getCOP0Encoding();
+ else if (Op.isNumericReg())
+ Encoding = MIPS_MC::encodeCOP0Register(Op.getNumericRegIndex(), 0);
+ else
+ return Error(S, "invalid operand for instruction");
+
+ const MCRegisterInfo &MRI = *getContext().getRegisterInfo();
+ if (getLexer().is(AsmToken::Comma)) {
+ Lex();
+ SMLoc SelLoc = getLexer().getLoc();
+ if (getLexer().is(AsmToken::Dollar))
+ return Error(SelLoc, "expected 3-bit unsigned immediate");
+ const MCExpr *Expr;
+ int64_t Sel;
+ if (getParser().parseExpression(Expr))
+ return ParseStatus::Failure;
+ if (!Expr->evaluateAsAbsolute(Sel) || !isUInt<3>(Sel))
+ return Error(SelLoc, "expected 3-bit unsigned immediate");
+ if (Op.isCOP0AsmReg() && Sel != MIPS_MC::getCOP0Sel(Encoding))
+ return Error(SelLoc, "selector does not match named COP0 register");
+ Encoding =
+ MIPS_MC::encodeCOP0Register(MIPS_MC::getCOP0RegNum(Encoding), Sel);
+ }
+ if (MIPS_MC::getCOP0Sel(Encoding) != 0 && !hasMips32())
+ return Error(S, "selector must be zero for pre-MIPS32 ISAs");
+
+ Operands.push_back(MipsOperand::createCOP0Reg(
+ Encoding, "", &MRI, S, getLexer().getLoc(), *this));
+ return ParseStatus::Success;
+}
+
ParseStatus MipsAsmParser::parseAnyRegister(OperandVector &Operands) {
MCAsmParser &Parser = getParser();
LLVM_DEBUG(dbgs() << "parseAnyRegister\n");
diff --git a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
index bbd614fc6442362..6bdd132b349bcf6 100644
--- a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
+++ b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp
@@ -219,10 +219,11 @@ static DecodeStatus DecodeMSACtrlRegisterClass(MCInst &Inst, unsigned RegNo,
static DecodeStatus DecodeCOP0RegisterClass(MCInst &Inst, unsigned RegNo,
uint64_t Address,
const MCDisassembler *Decoder) {
- if (RegNo > 31)
+ if (MIPS_MC::getCOP0RegNum(RegNo) >= 32 || MIPS_MC::getCOP0Sel(RegNo) >= 8)
return MCDisassembler::Fail;
- MCRegister Reg = getReg(Decoder, Mips::COP0RegClassID, RegNo);
+ MCRegister Reg =
+ MIPS_MC::getCOP0Register(*Decoder->getContext().getRegisterInfo(), RegNo);
Inst.addOperand(MCOperand::createReg(Reg));
return MCDisassembler::Success;
}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
index f67356c105a4d8f..19d39875305d8a1 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
@@ -17,6 +17,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorHandling.h"
@@ -72,6 +73,15 @@ const char* Mips::MipsFCCToString(Mips::CondCode CC) {
llvm_unreachable("Impossible condition code!");
}
+void MipsInstPrinter::printCOP0Operand(const MCInst *MI, unsigned OpNo,
+ const MCSubtargetInfo &STI,
+ raw_ostream &O) {
+ unsigned Encoding = MRI.getEncodingValue(MI->getOperand(OpNo).getReg());
+ markup(O, Markup::Register) << '$' << MIPS_MC::getCOP0RegNum(Encoding);
+ O << ", ";
+ markup(O, Markup::Immediate) << MIPS_MC::getCOP0Sel(Encoding);
+}
+
void MipsInstPrinter::printRegName(raw_ostream &OS, MCRegister Reg) {
markup(OS, Markup::Register)
<< '$' << StringRef(getRegisterName(Reg)).lower();
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h
index df540ddf2805149..7ecd50cbbef9f3d 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h
@@ -87,6 +87,8 @@ class MipsInstPrinter : public MCInstPrinter {
static const char *getRegisterName(MCRegister Reg,
unsigned AltIdx = Mips::NoRegAltName);
+ void printCOP0Operand(const MCInst *MI, unsigned OpNo,
+ const MCSubtargetInfo &STI, raw_ostream &O);
void printRegName(raw_ostream &OS, MCRegister Reg) override;
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
const MCSubtargetInfo &STI, raw_ostream &O) override;
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
index fb4cff6b25a1bb7..664d5e144b2c02c 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
@@ -48,6 +48,14 @@ using namespace llvm;
#define GET_REGISTER_MATCHER
#include "MipsGenAsmMatcher.inc"
+MCRegister MIPS_MC::getCOP0Register(const MCRegisterInfo &MRI, unsigned Encoding) {
+ unsigned Reg = getCOP0RegNum(Encoding);
+ unsigned Sel = getCOP0Sel(Encoding);
+ assert(Reg < 32 && Sel < 8 && "Invalid COP0 register encoding");
+ // COP0's register class is ordered by selector, then register number.
+ return MRI.getRegClass(Mips::COP0RegClassID).getRegister(Sel * 32 + Reg);
+}
+
MCRegister MIPS_MC::matchRegisterName(StringRef Name, const MCRegisterInfo &MRI,
unsigned RegClassID, unsigned AltIdx) {
MCRegister Reg = MatchRegisterAltName(Name, AltIdx);
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h
index db9b4bf23335392..cf0c5258c3a6ddd 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.h
@@ -60,6 +60,14 @@ std::unique_ptr<MCObjectTargetWriter> createMipsWinCOFFObjectWriter();
namespace MIPS_MC {
void initLLVMToCVRegMapping(MCRegisterInfo *MRI);
+/// COP0 hardware encodings reserve five bits each for REG and SEL.
+constexpr unsigned encodeCOP0Register(unsigned Reg, unsigned Sel) {
+ return (Reg << 5) | Sel;
+}
+constexpr unsigned getCOP0RegNum(unsigned Encoding) { return Encoding >> 5; }
+constexpr unsigned getCOP0Sel(unsigned Encoding) { return Encoding & 31; }
+MCRegister getCOP0Register(const MCRegisterInfo &MRI, unsigned Encoding);
+
StringRef selectMipsCPU(const Triple &TT, StringRef CPU);
/// Match a symbolic name in RegClassID, or return an invalid register.
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp
index fd8eb33e20b2674..1aaf280cd8453ec 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsOptionRecord.cpp
@@ -73,7 +73,11 @@ void MipsRegInfoRecord::SetPhysRegUsed(MCRegister Reg,
for (const MCPhysReg &SubReg : MCRegInfo->subregs_inclusive(Reg)) {
unsigned EncVal = MCRegInfo->getEncodingValue(SubReg);
- Value |= 1 << EncVal;
+ // COP0 HWEncoding packs REG and SEL, but the 32-bit ri_cprmask has one
+ // bit per REG regardless of SEL. Unpack REG before using it as a shift.
+ if (COP0RegClass->contains(SubReg))
+ EncVal = MIPS_MC::getCOP0RegNum(EncVal);
+ Value |= 1U << EncVal;
if (GPR32RegClass->contains(SubReg) || GPR64RegClass->contains(SubReg))
ri_gprmask |= Value;
diff --git a/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td b/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td
index 2770ccb410f5152..d320b1110358147 100644
--- a/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td
+++ b/llvm/lib/Target/Mips/MicroMips32r6InstrFormats.td
@@ -872,8 +872,9 @@ class POOL32A_TLBINV_FM_MMR6<string instr_asm, bits<10> funct>
class POOL32A_MFTC0_FM_MMR6<string instr_asm, bits<5> funct, bits<6> opcode>
: MMR6Arch<instr_asm>, MipsR6Inst {
bits<5> rt;
- bits<5> rs;
- bits<3> sel;
+ bits<10> cop0;
+ bits<5> rs = cop0{9-5};
+ bits<3> sel = cop0{2-0};
bits<32> Inst;
diff --git a/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td b/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td
index 5487254c14ab3f2..82edae93048c7c1 100644
--- a/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td
+++ b/llvm/lib/Target/Mips/MicroMips32r6InstrInfo.td
@@ -629,9 +629,9 @@ class WSBH_MMR6_DESC : WRPGPR_WSBH_MMR6_DESC_BASE<"wsbh", GPR32Opnd>;
class MTC0_MMR6_DESC_BASE<string opstr, RegisterOperand DstRC,
RegisterOperand SrcRC> {
- dag InOperandList = (ins SrcRC:$rt, uimm3:$sel);
- dag OutOperandList = (outs DstRC:$rs);
- string AsmString = !strconcat(opstr, "\t$rt, $rs, $sel");
+ dag InOperandList = (ins SrcRC:$rt);
+ dag OutOperandList = (outs DstRC:$cop0);
+ string AsmString = !strconcat(opstr, "\t$rt, $cop0");
list<dag> Pattern = [];
Format f = FrmFR;
string BaseOpcode = opstr;
@@ -679,9 +679,9 @@ class MTHC2_MMR6_DESC : MTC2_MMR6_DESC_BASE<"mthc2", COP2Opnd, GPR32Opnd>;
class MFC0_MMR6_DESC_BASE<string opstr, RegisterOperand DstRC,
RegisterOperand SrcRC> {
- dag InOperandList = (ins SrcRC:$rs, uimm3:$sel);
+ dag InOperandList = (ins SrcRC:$cop0);
dag OutOperandList = (outs DstRC:$rt);
- string AsmString = !strconcat(opstr, "\t$rt, $rs, $sel");
+ string AsmString = !strconcat(opstr, "\t$rt, $cop0");
list<dag> Pattern = [];
Format f = FrmFR;
string BaseOpcode = opstr;
@@ -1594,18 +1594,6 @@ def : MipsInstAlias<"sigrie", (SIGRIE_MMR6 0), 1>, ISA_MICROMIPS32R6;
def : MipsInstAlias<"rdhwr $rt, $rs",
(RDHWR_MMR6 GPR32Opnd:$rt, HWRegsOpnd:$rs, 0), 1>,
ISA_MICROMIPS32R6;
-def : MipsInstAlias<"mtc0 $rt, $rs",
- (MTC0_MMR6 COP0Opnd:$rs, GPR32Opnd:$rt, 0), 0>,
- ISA_MICROMIPS32R6;
-def : MipsInstAlias<"mthc0 $rt, $rs",
- (MTHC0_MMR6 COP0Opnd:$rs, GPR32Opnd:$rt, 0), 0>,
- ISA_MICROMIPS32R6;
-def : MipsInstAlias<"mfc0 $rt, $rs",
- (MFC0_MMR6 GPR32Opnd:$rt, COP0Opnd:$rs, 0), 0>,
- ISA_MICROMIPS32R6;
-def : MipsInstAlias<"mfhc0 $rt, $rs",
- (MFHC0_MMR6 GPR32Opnd:$rt, COP0Opnd:$rs, 0), 0>,
- ISA_MICROMIPS32R6;
def : MipsInstAlias<"jalrc.hb $rs", (JALRC_HB_MMR6 RA, GPR32Opnd:$rs), 1>,
ISA_MICROMIPS32R6;
def : MipsInstAlias<"jal $offset", (BALC_MMR6 brtarget26_mm:$offset), 0>,
diff --git a/llvm/lib/Target/Mips/MicroMipsInstrFormats.td b/llvm/lib/Target/Mips/MicroMipsInstrFormats.td
index faaa9bc15efdf04..f8288c573d18fec 100644
--- a/llvm/lib/Target/Mips/MicroMipsInstrFormats.td
+++ b/llvm/lib/Target/Mips/MicroMipsInstrFormats.td
@@ -870,8 +870,9 @@ class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
class MFC0_FM_MM<bits<11> funct> : MMArch {
bits<5> rt;
- bits<5> rd;
- bits<3> sel;
+ bits<10> cop0;
+ bits<5> rd = cop0{9-5};
+ bits<3> sel = cop0{2-0};
bits<32> Inst;
@@ -1101,8 +1102,9 @@ class POOL32A_TLBINV_FM_MM<bits<10> funct> : MMArch {
class POOL32A_MFTC0_FM_MM<bits<5> funct, bits<6> opcode> : MMArch {
bits<5> rt;
- bits<5> rs;
- bits<3> sel;
+ bits<10> cop0;
+ bits<5> rs = cop0{9-5};
+ bits<3> sel = cop0{2-0};
bits<32> Inst;
diff --git a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td
index d5f3ced35485b77..990636a77094a90 100644
--- a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td
@@ -580,15 +580,15 @@ class TLBINVMM<string opstr> :
class MfCop0MM<string opstr, RegisterOperand DstRC,
RegisterOperand SrcRC> :
- InstSE<(outs DstRC:$rt), (ins SrcRC:$rs, uimm3:$sel),
- !strconcat(opstr, "\t$rt, $rs, $sel"), [], FrmR> {
+ InstSE<(outs DstRC:$rt), (ins SrcRC:$cop0),
+ !strconcat(opstr, "\t$rt, $cop0"), [], FrmR> {
let BaseOpcode = opstr;
}
class MtCop0MM<string opstr, RegisterOperand DstRC,
RegisterOperand SrcRC> :
- InstSE<(outs DstRC:$rs), (ins SrcRC:$rt, uimm3:$sel),
- !strconcat(opstr, "\t$rt, $rs, $sel"), [], FrmR> {
+ InstSE<(outs DstRC:$cop0), (ins SrcRC:$rt),
+ !strconcat(opstr, "\t$rt, $cop0"), [], FrmR> {
let BaseOpcode = opstr;
}
@@ -1056,9 +1056,9 @@ let DecoderNamespace = "MicroMips" in {
def PAUSE_MM : MMRel, Barrier<"pause">, BARRIER_FM_MM<0x5>,
ISA_MICROMIPS;
- def MFC0_MM : MFC3OP<"mfc0", GPR32Opnd, COP0Opnd>,
+ def MFC0_MM : MFC0OP<"mfc0", GPR32Opnd, COP0Opnd>,
MFC0_FM_MM<0x0fc>, ISA_MICROMIPS32_NOT_MIPS32R6;
- def MTC0_MM : MTC3OP<"mtc0", COP0Opnd, GPR32Opnd>,
+ def MTC0_MM : MTC0OP<"mtc0", COP0Opnd, GPR32Opnd>,
MFC0_FM_MM<0x2fc>, ISA_MICROMIPS32_NOT_MIPS32R6;
def TLBP_MM : MMRel, TLB<"tlbp">, COP0_TLB_FM_MM<0x0d>,
@@ -1297,12 +1297,6 @@ class UncondBranchMMPseudo<string opstr> :
def B_MM_Pseudo : UncondBranchMMPseudo<"b">, ISA_MICROMIPS;
let EncodingPredicates = [InMicroMips] in {
- def : MipsInstAlias<"mfc0 $rt, $rd",
- (MFC0_MM GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>,
- ISA_MICROMIPS32_NOT_MIPS32R6;
- def : MipsInstAlias<"mtc0 $rt, $rd",
- (MTC0_MM COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>,
- ISA_MICROMIPS32_NOT_MIPS32R6;
def SDIV_MM_Pseudo : MultDivPseudo<SDIV_MM, ACC64, GPR32Opnd, MipsDivRem,
0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6;
def UDIV_MM_Pseudo : MultDivPseudo<UDIV_MM, ACC64, GPR32Opnd, MipsDivRemU,
@@ -1421,18 +1415,6 @@ def : MipsInstAlias<"rdhwr $rt, $rs",
def : MipsInstAlias<"hypcall", (HYPCALL_MM 0), 1>,
ISA_MICROMIPS32R5, ASE_VIRT;
-def : MipsInstAlias<"mfgc0 $rt, $rs",
- (MFGC0_MM GPR32Opnd:$rt, COP0Opnd:$rs, 0), 0>,
- ISA_MICROMIPS32R5, ASE_VIRT;
-def : MipsInstAlias<"mfhgc0 $rt, $rs",
- (MFHGC0_MM GPR32Opnd:$rt, COP0Opnd:$rs, 0), 0>,
- ISA_MICROMIPS32R5, ASE_VIRT;
-def : MipsInstAlias<"mtgc0 $rt, $rs",
- (MTGC0_MM COP0Opnd:$rs, GPR32Opnd:$rt, 0), 0>,
- ISA_MICROMIPS32R5, ASE_VIRT;
-def : MipsInstAlias<"mthgc0 $rt, $rs",
- (MTHGC0_MM COP0Opnd:$rs, GPR32Opnd:$rt, 0), 0>,
- ISA_MICROMIPS32R5, ASE_VIRT;
def : MipsInstAlias<"sw $rt, $offset",
(SWSP_MM GPR32Opnd:$rt, mem_mm_sp_imm5_lsl2:$offset), 1>,
ISA_MICROMIPS;
diff --git a/llvm/lib/Target/Mips/Mips64InstrInfo.td b/llvm/lib/Target/Mips/Mips64InstrInfo.td
index b6d820bbc10256d..87ad0ed1603a76e 100644
--- a/llvm/lib/Target/Mips/Mips64InstrInfo.td
+++ b/llvm/lib/Target/Mips/Mips64InstrInfo.td
@@ -630,10 +630,10 @@ def SaadAddr : MipsAsmPseudoInst<(outs), (ins GPR64Opnd:$rt, mem:$addr),
/// Move between CPU and coprocessor registers
let DecoderNamespace = "Mips64" in {
-def DMFC0 : MFC3OP<"dmfc0", GPR64Opnd, COP0Opnd>,
- MFC3OP_FM<0x10, 1, 0>, ISA_MIPS3, GPR_64;
-def DMTC0 : MTC3OP<"dmtc0", COP0Opnd, GPR64Opnd>,
- MFC3OP_FM<0x10, 5, 0>, ISA_MIPS3, GPR_64;
+def DMFC0 : MFC0OP<"dmfc0", GPR64Opnd, COP0Opnd>,
+ MFC0OP_FM<1, 0>, ISA_MIPS3, GPR_64;
+def DMTC0 : MTC0OP<"dmtc0", COP0Opnd, GPR64Opnd>,
+ MFC0OP_FM<5, 0>, ISA_MIPS3, GPR_64;
def DMFC2 : MFC3OP<"dmfc2", GPR64Opnd, COP2Opnd>,
MFC3OP_FM<0x12, 1, 0>, ISA_MIPS3, GPR_64;
def DMTC2 : MTC3OP<"dmtc2", COP2Opnd, GPR64Opnd>,
@@ -642,10 +642,10 @@ def DMTC2 : MTC3OP<"dmtc2", COP2Opnd, GPR64Opnd>,
/// Move between CPU and guest coprocessor registers (Virtualization ASE)
let DecoderNamespace = "Mips64" in {
- def DMFGC0 : MFC3OP<"dmfgc0", GPR64Opnd, COP0Opnd>,
- MFC3OP_FM<0x10, 3, 1>, ISA_MIPS64R5, ASE_VIRT;
- def DMTGC0 : MTC3OP<"dmtgc0", COP0Opnd, GPR64Opnd>,
- MFC3OP_FM<0x10, 3, 3>, ISA_MIPS64R5, ASE_VIRT;
+ def DMFGC0 : MFC0OP<"dmfgc0", GPR64Opnd, COP0Opnd>,
+ MFC0OP_FM<3, 1>, ISA_MIPS64R5, ASE_VIRT;
+ def DMTGC0 : MTC0OP<"dmtgc0", COP0Opnd, GPR64Opnd>,
+ MFC0OP_FM<3, 3>, ISA_MIPS64R5, ASE_VIRT;
}
let AdditionalPredicates = [UseIndirectJumpsHazard] in
@@ -1064,18 +1064,8 @@ let AdditionalPredicates = [NotInMicroMips] in {
uimm5_plus1:$size), 0>, ISA_MIPS64R2;
def : MipsInstAlias<"jalr.hb $rs", (JALR_HB64 RA_64, GPR64Opnd:$rs), 1>,
ISA_MIPS64;
-// Two operand (implicit 0 selector) versions:
- def : MipsInstAlias<"dmtc0 $rt, $rd",
- (DMTC0 COP0Opnd:$rd, GPR64Opnd:$rt, 0), 0>;
- def : MipsInstAlias<"dmfc0 $rt, $rd",
- (DMFC0 GPR64Opnd:$rt, COP0Opnd:$rd, 0), 0>;
- def : MipsInstAlias<"dmfgc0 $rt, $rd",
- (DMFGC0 GPR64Opnd:$rt, COP0Opnd:$rd, 0), 0>,
- ISA_MIPS64R5, ASE_VIRT;
- def : MipsInstAlias<"dmtgc0 $rt, $rd",
- (DMTGC0 COP0Opnd:$rd, GPR64Opnd:$rt, 0), 0>,
- ISA_MIPS64R5, ASE_VIRT;
}
+// Two operand (implicit 0 selector) versions:
def : MipsInstAlias<"dmfc2 $rt, $rd",
(DMFC2 GPR64Opnd:$rt, COP2Opnd:$rd, 0), 0>;
def : MipsInstAlias<"dmtc2 $rt, $rd",
diff --git a/llvm/lib/Target/Mips/MipsInstrFormats.td b/llvm/lib/Target/Mips/MipsInstrFormats.td
index 5240550130d3cca..564e6f6cc0d9a5a 100644
--- a/llvm/lib/Target/Mips/MipsInstrFormats.td
+++ b/llvm/lib/Target/Mips/MipsInstrFormats.td
@@ -197,6 +197,13 @@ class MFC3OP_FM<bits<6> op, bits<5> mfmt, bits<3> guest> : StdArch {
let Inst{2-0} = sel;
}
+class MFC0OP_FM<bits<5> mfmt, bits<3> guest>
+ : MFC3OP_FM<0x10, mfmt, guest> {
+ bits<10> cop0;
+ let rd = cop0{9-5};
+ let sel = cop0{2-0};
+}
+
class MFC2OP_FM<bits<6> op, bits<5> mfmt> : StdArch {
bits<5> rt;
bits<16> imm16;
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td
index 73824b28340e499..4738f72f99af881 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.td
@@ -1887,6 +1887,18 @@ class SCBase<string opstr, RegisterOperand RO> :
let Constraints = "$rt = $dst";
}
+class MFC0OP<string asmstr, RegisterOperand RO, RegisterOperand RD> :
+ InstSE<(outs RO:$rt), (ins RD:$cop0),
+ !strconcat(asmstr, "\t$rt, $cop0"), [], FrmFR> {
+ let BaseOpcode = asmstr;
+}
+
+class MTC0OP<string asmstr, RegisterOperand RO, RegisterOperand RD> :
+ InstSE<(outs RO:$cop0), (ins RD:$rt),
+ !strconcat(asmstr, "\t$rt, $cop0"), [], FrmFR> {
+ let BaseOpcode = asmstr;
+}
+
class MFC3OP<string asmstr, RegisterOperand RO, RegisterOperand RD> :
InstSE<(outs RO:$rt), (ins RD:$rd, uimm3:$sel),
!strconcat(asmstr, "\t$rt, $rd, $sel"), [], FrmFR> {
@@ -2474,10 +2486,10 @@ let AdditionalPredicates = [NotInMicroMips] in {
}
/// Move Control Registers From/To CPU Registers
let AdditionalPredicates = [NotInMicroMips] in {
- def MTC0 : MTC3OP<"mtc0", COP0Opnd, GPR32Opnd>,
- MFC3OP_FM<0x10, 4, 0>, ISA_MIPS1;
- def MFC0 : MFC3OP<"mfc0", GPR32Opnd, COP0Opnd>,
- MFC3OP_FM<0x10, 0, 0>, ISA_MIPS1;
+ def MTC0 : MTC0OP<"mtc0", COP0Opnd, GPR32Opnd>,
+ MFC0OP_FM<4, 0>, ISA_MIPS1;
+ def MFC0 : MFC0OP<"mfc0", GPR32Opnd, COP0Opnd>,
+ MFC0OP_FM<0, 0>, ISA_MIPS1;
def MFC2 : MFC3OP<"mfc2", GPR32Opnd, COP2Opnd>,
MFC3OP_FM<0x12, 0, 0>, ISA_MIPS1;
def MTC2 : MTC3OP<"mtc2", COP2Opnd, GPR32Opnd>,
@@ -2678,14 +2690,14 @@ class HYPCALL_FT<string opstr> :
}
let AdditionalPredicates = [NotInMicroMips] in {
- def MFGC0 : MMRel, MFC3OP<"mfgc0", GPR32Opnd, COP0Opnd>,
- MFC3OP_FM<0x10, 3, 0>, ISA_MIPS32R5, ASE_VIRT;
- def MTGC0 : MMRel, MTC3OP<"mtgc0", COP0Opnd, GPR32Opnd>,
- MFC3OP_FM<0x10, 3, 2>, ISA_MIPS32R5, ASE_VIRT;
- def MFHGC0 : MMRel, MFC3OP<"mfhgc0", GPR32Opnd, COP0Opnd>,
- MFC3OP_FM<0x10, 3, 4>, ISA_MIPS32R5, ASE_VIRT;
- def MTHGC0 : MMRel, MTC3OP<"mthgc0", COP0Opnd, GPR32Opnd>,
- MFC3OP_FM<0x10, 3, 6>, ISA_MIPS32R5, ASE_VIRT;
+ def MFGC0 : MMRel, MFC0OP<"mfgc0", GPR32Opnd, COP0Opnd>,
+ MFC0OP_FM<3, 0>, ISA_MIPS32R5, ASE_VIRT;
+ def MTGC0 : MMRel, MTC0OP<"mtgc0", COP0Opnd, GPR32Opnd>,
+ MFC0OP_FM<3, 2>, ISA_MIPS32R5, ASE_VIRT;
+ def MFHGC0 : MMRel, MFC0OP<"mfhgc0", GPR32Opnd, COP0Opnd>,
+ MFC0OP_FM<3, 4>, ISA_MIPS32R5, ASE_VIRT;
+ def MTHGC0 : MMRel, MTC0OP<"mthgc0", COP0Opnd, GPR32Opnd>,
+ MFC0OP_FM<3, 6>, ISA_MIPS32R5, ASE_VIRT;
def TLBGINV : MMRel, TLB<"tlbginv">, COP0_TLB_FM<0b001011>,
ISA_MIPS32R5, ASE_VIRT;
def TLBGINVF : MMRel, TLB<"tlbginvf">, COP0_TLB_FM<0b001100>,
@@ -2858,22 +2870,6 @@ let AdditionalPredicates = [NotInMicroMips] in {
defm : OneOrTwoOperandMacroImmediateAlias<"sltu", SLTiu>, ISA_MIPS1, GPR_32;
- def : MipsInstAlias<"mfgc0 $rt, $rd",
- (MFGC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>,
- ISA_MIPS32R5, ASE_VIRT;
- def : MipsInstAlias<"mtgc0 $rt, $rd",
- (MTGC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>,
- ISA_MIPS32R5, ASE_VIRT;
- def : MipsInstAlias<"mfhgc0 $rt, $rd",
- (MFHGC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>,
- ISA_MIPS32R5, ASE_VIRT;
- def : MipsInstAlias<"mthgc0 $rt, $rd",
- (MTHGC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>,
- ISA_MIPS32R5, ASE_VIRT;
- def : MipsInstAlias<"mfc0 $rt, $rd", (MFC0 GPR32Opnd:$rt, COP0Opnd:$rd, 0), 0>,
- ISA_MIPS1;
- def : MipsInstAlias<"mtc0 $rt, $rd", (MTC0 COP0Opnd:$rd, GPR32Opnd:$rt, 0), 0>,
- ISA_MIPS1;
def : MipsInstAlias<"mfc2 $rt, $rd", (MFC2 GPR32Opnd:$rt, COP2Opnd:$rd, 0), 0>,
ISA_MIPS1;
def : MipsInstAlias<"mtc2 $rt, $rd", (MTC2 COP2Opnd:$rd, GPR32Opnd:$rt, 0), 0>,
diff --git a/llvm/lib/Target/Mips/MipsMTInstrInfo.td b/llvm/lib/Target/Mips/MipsMTInstrInfo.td
index 4cb609df0639be7..4be35ac944aa365 100644
--- a/llvm/lib/Target/Mips/MipsMTInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsMTInstrInfo.td
@@ -109,9 +109,17 @@ let hasSideEffects = 1, isNotDuplicable = 1,
//===----------------------------------------------------------------------===//
// MIPS MT Pseudo Instructions - used to support mtfr & mttr aliases.
//===----------------------------------------------------------------------===//
-def MFTC0 : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins COP0Opnd:$rt,
- uimm3:$sel),
- "mftc0 $rd, $rt, $sel">, ASE_MT;
+// Convert COP0 operands to the generic MFTR/MTTR operands during matching.
+let AdditionalPredicates = [NotInMicroMips] in {
+ def MFTC0 : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins COP0Opnd:$cop0),
+ "mftc0 $rt, $cop0">, ASE_MT {
+ let AsmMatchConverter = "ConvertMFTC0Operands";
+ }
+ def MTTC0 : MipsAsmPseudoInst<(outs COP0Opnd:$cop0), (ins GPR32Opnd:$rt),
+ "mttc0 $rt, $cop0">, ASE_MT {
+ let AsmMatchConverter = "ConvertMTTC0Operands";
+ }
+}
def MFTGPR : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rt,
uimm3:$sel),
@@ -139,10 +147,6 @@ def CFTC1 : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins FGR32CCOpnd:$ft),
"cftc1 $rt, $ft">, ASE_MT;
-def MTTC0 : MipsAsmPseudoInst<(outs COP0Opnd:$rd), (ins GPR32Opnd:$rt,
- uimm3:$sel),
- "mttc0 $rt, $rd, $sel">, ASE_MT;
-
def MTTGPR : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins GPR32Opnd:$rd),
"mttgpr $rd, $rt">, ASE_MT;
@@ -182,18 +186,12 @@ let AdditionalPredicates = [NotInMicroMips] in {
def : MipsInstAlias<"yield $rs", (YIELD ZERO, GPR32Opnd:$rs), 1>, ASE_MT;
- def : MipsInstAlias<"mftc0 $rd, $rt", (MFTC0 GPR32Opnd:$rd, COP0Opnd:$rt, 0),
- 1>, ASE_MT;
-
def : MipsInstAlias<"mftlo $rt", (MFTLO GPR32Opnd:$rt, AC0), 1>, ASE_MT;
def : MipsInstAlias<"mfthi $rt", (MFTHI GPR32Opnd:$rt, AC0), 1>, ASE_MT;
def : MipsInstAlias<"mftacx $rt", (MFTACX GPR32Opnd:$rt, AC0), 1>, ASE_MT;
- def : MipsInstAlias<"mttc0 $rd, $rt", (MTTC0 COP0Opnd:$rt, GPR32Opnd:$rd, 0),
- 1>, ASE_MT;
-
def : MipsInstAlias<"mttlo $rt", (MTTLO AC0, GPR32Opnd:$rt), 1>, ASE_MT;
def : MipsInstAlias<"mtthi $rt", (MTTHI AC0, GPR32Opnd:$rt), 1>, ASE_MT;
diff --git a/llvm/lib/Target/Mips/MipsRegisterInfo.td b/llvm/lib/Target/Mips/MipsRegisterInfo.td
index a1c775060786db6..4aa862f7553980d 100644
--- a/llvm/lib/Target/Mips/MipsRegisterInfo.td
+++ b/llvm/lib/Target/Mips/MipsRegisterInfo.td
@@ -97,6 +97,18 @@ class ACCReg<bits<16> Enc, string n, list<Register> subregs>
// Mips Hardware Registers
class HWR<bits<16> Enc, string n> : MipsReg<Enc, n>;
+class MipsCP0Reg<bits<5> reg, bits<5> sel, string name>
+ : MipsReg<!or(!shl(reg, 5), sel), name>;
+
+multiclass CP0Registers<int reg, list<string> names = []> {
+ foreach sel = 0-7 in {
+ defvar regName = !if(!lt(sel, !size(names)), names[sel], "");
+ def NAME # !if(!eq(sel, 0), "", "_" # sel)
+ : MipsCP0Reg<reg, sel,
+ !if(!empty(regName), "cop0_" # reg # "_" # sel, regName)>;
+ }
+}
+
//===----------------------------------------------------------------------===//
// Registers
//===----------------------------------------------------------------------===//
@@ -223,9 +235,50 @@ let Namespace = "Mips" in {
foreach I = 0-7 in
def FCC#I : MipsReg<I, "fcc"#I>;
- // COP0 registers.
- foreach I = 0-31 in
- def COP0#I : MipsReg<I, ""#I>;
+ // Each COP0 register is identified by its register number and selector.
+ defm COP00 : CP0Registers<0, ["index", "mvpcontrol", "mvpconf0", "mvpconf1"]>;
+ defm COP01 : CP0Registers<1, ["random", "vpecontrol", "vpeconf0", "vpeconf1",
+ "yqmask", "vpeschedule", "vpeschefback"]>;
+ defm COP02 : CP0Registers<2, ["entrylo0", "tcstatus", "tcbind", "tcrestart",
+ "tchalt", "tccontext", "tcschedule", "tcschefback"]>;
+ defm COP03 : CP0Registers<3, ["entrylo1"]>;
+ defm COP04 : CP0Registers<4, ["context", "contextconfig", "userlocal"]>;
+ defm COP05 : CP0Registers<5, ["pagemask", "pagegrain", "segctl0", "segctl1",
+ "segctl2", "pwbase", "pwfield", "pwsize"]>;
+ defm COP06 : CP0Registers<6, ["wired", "srsconf0", "srsconf1", "srsconf2",
+ "srsconf3", "srsconf4", "pwctl"]>;
+ defm COP07 : CP0Registers<7, ["hwrena"]>;
+ defm COP08 : CP0Registers<8, ["badvaddr", "badinstr", "badinstrp"]>;
+ defm COP09 : CP0Registers<9, ["count"]>;
+ defm COP010 : CP0Registers<10, ["entryhi", "", "", "", "guestctl1", "guestctl2",
+ "guestctl3"]>;
+ defm COP011 : CP0Registers<11, ["compare", "", "", "", "guestctl0ext"]>;
+ defm COP012 : CP0Registers<12, ["status", "intctl", "srsctl", "srsmap", "",
+ "", "guestctl0", "gtoffset"]>;
+ defm COP013 : CP0Registers<13, ["cause"]>;
+ defm COP014 : CP0Registers<14, ["epc"]>;
+ defm COP015 : CP0Registers<15, ["prid", "ebase", "cdmmbase", "cmgcrbase"]>;
+ defm COP016 : CP0Registers<16, ["config", "config1", "config2", "config3",
+ "config4", "config5", "config6", "config7"]>;
+ defm COP017 : CP0Registers<17, ["lladdr", "maar", "maari"]>;
+ defm COP018 : CP0Registers<18, !foreach(I, !range(8), "watchlo" # I)>;
+ defm COP019 : CP0Registers<19, !foreach(I, !range(8), "watchhi" # I)>;
+ defm COP020 : CP0Registers<20, ["xcontext"]>;
+ defm COP021 : CP0Registers<21>;
+ defm COP022 : CP0Registers<22>;
+ defm COP023 : CP0Registers<23, ["debug", "tracecontrol", "tracecontrol2",
+ "usertracedata1", "traceibpc", "tracedbpc",
+ "debug2"]>;
+ defm COP024 : CP0Registers<24, ["depc", "", "tracecontrol3", "usertracedata2"]>;
+ defm COP025 : CP0Registers<25, ["perfctl0", "perfcnt0", "perfctl1", "perfcnt1",
+ "perfctl2", "perfcnt2", "perfctl3", "perfcnt3"]>;
+ defm COP026 : CP0Registers<26, ["errctl"]>;
+ defm COP027 : CP0Registers<27, ["cacheerr"]>;
+ defm COP028 : CP0Registers<28, ["taglo", "datalo"]>;
+ defm COP029 : CP0Registers<29, ["taghi", "datahi"]>;
+ defm COP030 : CP0Registers<30, ["errorepc"]>;
+ defm COP031 : CP0Registers<31, ["desave", "", "kscratch1", "kscratch2",
+ "kscratch3", "kscratch4", "kscratch5", "kscratch6"]>;
// COP2 registers.
foreach I = 0-31 in
@@ -498,8 +551,13 @@ def ACC64DSP : RegisterClass<"Mips", [untyped], 64, (sequence "AC%u", 0, 3)> {
def DSPCC : RegisterClass<"Mips", [v4i8, v2i16], 32, (add DSPCCond)>;
// Coprocessor 0 registers.
-def COP0 : RegisterClass<"Mips", [i32], 32, (sequence "COP0%u", 0, 31)>,
- Unallocatable;
+// Ordered by selector, then register number; see MIPS_MC::getCOP0Register.
+def COP0 : RegisterClass<"Mips", [i32], 32, (add
+ (sequence "COP0%u", 0, 31),
+ (sequence "COP0%u_1", 0, 31), (sequence "COP0%u_2", 0, 31),
+ (sequence "COP0%u_3", 0, 31), (sequence "COP0%u_4", 0, 31),
+ (sequence "COP0%u_5", 0, 31), (sequence "COP0%u_6", 0, 31),
+ (sequence "COP0%u_7", 0, 31))>, Unallocatable;
// Coprocessor 2 registers.
def COP2 : RegisterClass<"Mips", [i32], 32, (sequence "COP2%u", 0, 31)>,
@@ -685,6 +743,7 @@ def HWRegsAsmOperand : MipsAsmRegOperand {
def COP0AsmOperand : MipsAsmRegOperand {
let Name = "COP0AsmReg";
+ let ParserMethod = "parseCOP0Register";
}
def COP2AsmOperand : MipsAsmRegOperand {
@@ -753,6 +812,7 @@ def ACC64DSPOpnd : RegisterOperand<ACC64DSP> {
def COP0Opnd : RegisterOperand<COP0> {
let ParserMatchClass = COP0AsmOperand;
+ let PrintMethod = "printCOP0Operand";
}
def COP2Opnd : RegisterOperand<COP2> {
diff --git a/llvm/lib/Target/Mips/MipsSEFrameLowering.cpp b/llvm/lib/Target/Mips/MipsSEFrameLowering.cpp
index d4891152337ad55..9a4a34b401f1ab9 100644
--- a/llvm/lib/Target/Mips/MipsSEFrameLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsSEFrameLowering.cpp
@@ -546,7 +546,6 @@ void MipsSEFrameLowering::emitInterruptPrologueStub(
MBB.addLiveIn(Mips::COP013);
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MFC0), Mips::K0)
.addReg(Mips::COP013)
- .addImm(0)
.setMIFlag(MachineInstr::FrameSetup);
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::EXT), Mips::K0)
@@ -560,7 +559,6 @@ void MipsSEFrameLowering::emitInterruptPrologueStub(
MBB.addLiveIn(Mips::COP014);
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MFC0), Mips::K1)
.addReg(Mips::COP014)
- .addImm(0)
.setMIFlag(MachineInstr::FrameSetup);
STI.getInstrInfo()->storeRegToStack(MBB, MBBI, Mips::K1, false,
@@ -570,7 +568,6 @@ void MipsSEFrameLowering::emitInterruptPrologueStub(
MBB.addLiveIn(Mips::COP012);
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MFC0), Mips::K1)
.addReg(Mips::COP012)
- .addImm(0)
.setMIFlag(MachineInstr::FrameSetup);
STI.getInstrInfo()->storeRegToStack(MBB, MBBI, Mips::K1, false,
@@ -628,7 +625,6 @@ void MipsSEFrameLowering::emitInterruptPrologueStub(
// Set the new status
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MTC0), Mips::COP012)
.addReg(Mips::K1)
- .addImm(0)
.setMIFlag(MachineInstr::FrameSetup);
}
@@ -706,15 +702,13 @@ void MipsSEFrameLowering::emitInterruptEpilogueStub(
STI.getInstrInfo()->loadRegFromStackSlot(
MBB, MBBI, Mips::K1, MipsFI->getISRRegFI(0), PtrRC, Register());
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MTC0), Mips::COP014)
- .addReg(Mips::K1)
- .addImm(0);
+ .addReg(Mips::K1);
// Restore Status
STI.getInstrInfo()->loadRegFromStackSlot(
MBB, MBBI, Mips::K1, MipsFI->getISRRegFI(1), PtrRC, Register());
BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MTC0), Mips::COP012)
- .addReg(Mips::K1)
- .addImm(0);
+ .addReg(Mips::K1);
}
StackOffset
diff --git a/llvm/test/CodeGen/Mips/cop0-registers.mir b/llvm/test/CodeGen/Mips/cop0-registers.mir
new file mode 100644
index 000000000000000..fa1baac05d8c781
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/cop0-registers.mir
@@ -0,0 +1,26 @@
+# RUN: llc -mtriple=mips -mcpu=mips32r2 -run-pass=none -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=MIR
+# RUN: llc -mtriple=mips -mcpu=mips32r2 -start-after=xray-instrumentation -verify-machineinstrs -show-mc-encoding %s -o - | FileCheck %s --check-prefix=ASM
+
+# Selectors distinguish physical registers even when REG is the same. Each
+# transfer has one COP0 register operand and no separate selector immediate.
+---
+name: cop0_registers
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $cop016, $cop016_1
+
+ ; MIR: $v0 = MFC0 $cop016
+ ; MIR-NEXT: $v1 = MFC0 $cop016_1
+ ; MIR-NEXT: $cop016_1 = MTC0 $v0
+ ; MIR-NEXT: $cop016 = MTC0 $v1
+ ; ASM: mfc0 $2, $16, 0 # encoding: [0x40,0x02,0x80,0x00]
+ ; ASM: mfc0 $3, $16, 1 # encoding: [0x40,0x03,0x80,0x01]
+ ; ASM: mtc0 $2, $16, 1 # encoding: [0x40,0x82,0x80,0x01]
+ ; ASM: mtc0 $3, $16, 0 # encoding: [0x40,0x83,0x80,0x00]
+ $v0 = MFC0 $cop016
+ $v1 = MFC0 $cop016_1
+ $cop016_1 = MTC0 $v0
+ $cop016 = MTC0 $v1
+
+...
diff --git a/llvm/test/MC/Mips/cop0-register-invalid.s b/llvm/test/MC/Mips/cop0-register-invalid.s
new file mode 100644
index 000000000000000..50e740b4f461486
--- /dev/null
+++ b/llvm/test/MC/Mips/cop0-register-invalid.s
@@ -0,0 +1,11 @@
+# RUN: not llvm-mc -triple=mips -mcpu=mips32r2 %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple=mips -mcpu=mips32r6 -mattr=+micromips %s 2>&1 | FileCheck %s
+
+ mfc0 $2, $config1, 0 # CHECK: :[[@LINE]]:31: error: selector does not match named COP0 register
+ mtc0 $2, $status, 1 # CHECK: :[[@LINE]]:30: error: selector does not match named COP0 register
+ mfc0 $2, $16, 8 # CHECK: :[[@LINE]]:26: error: expected 3-bit unsigned immediate
+ mtc0 $2, $16, -1 # CHECK: :[[@LINE]]:26: error: expected 3-bit unsigned immediate
+ mfc0 $2, $t0 # CHECK: :[[@LINE]]:21: error: invalid operand for instruction
+ addu $config1, $2, $3 # CHECK: :[[@LINE]]:17: error: invalid operand for instruction
+ mfc0 $config1, $16, 1 # CHECK: :[[@LINE]]:17: error: invalid operand for instruction
+ mfc2 $2, $config1, 1 # CHECK: :[[@LINE]]:21: error: invalid operand for instruction
diff --git a/llvm/test/MC/Mips/cop0-register-isa.s b/llvm/test/MC/Mips/cop0-register-isa.s
new file mode 100644
index 000000000000000..81b15279979d0da
--- /dev/null
+++ b/llvm/test/MC/Mips/cop0-register-isa.s
@@ -0,0 +1,17 @@
+# RUN: not llvm-mc -triple=mips64 -mcpu=mips3 -show-encoding %s > %t.out 2> %t.err
+# RUN: FileCheck %s --check-prefix=ERR < %t.err
+# RUN: FileCheck %s --check-prefix=ENC < %t.out
+
+# Named registers carry the same selector restrictions as numeric REG/SEL pairs.
+ mfc0 $2, $config # ENC: mfc0 $2, $16, 0 # encoding: [0x40,0x02,0x80,0x00]
+ mtc0 $2, $16 # ENC: mtc0 $2, $16, 0 # encoding: [0x40,0x82,0x80,0x00]
+ mfc0 $2, $config1 # ERR: :[[@LINE]]:21: error: selector must be zero for pre-MIPS32 ISAs
+ mtc0 $2, $16, 1 # ERR: :[[@LINE]]:21: error: selector must be zero for pre-MIPS32 ISAs
+ dmfc0 $2, $config1 # ERR: :[[@LINE]]:21: error: selector must be zero for pre-MIPS32 ISAs
+ dmtc0 $2, $16, 1 # ERR: :[[@LINE]]:21: error: selector must be zero for pre-MIPS32 ISAs
+
+ .set mips64
+ mfc0 $2, $config1 # ENC: mfc0 $2, $16, 1 # encoding: [0x40,0x02,0x80,0x01]
+ mtc0 $2, $16, 1 # ENC: mtc0 $2, $16, 1 # encoding: [0x40,0x82,0x80,0x01]
+ dmfc0 $2, $config1 # ENC: dmfc0 $2, $16, 1 # encoding: [0x40,0x22,0x80,0x01]
+ dmtc0 $2, $16, 1 # ENC: dmtc0 $2, $16, 1 # encoding: [0x40,0xa2,0x80,0x01]
diff --git a/llvm/test/MC/Mips/cop0-register-names.s b/llvm/test/MC/Mips/cop0-register-names.s
new file mode 100644
index 000000000000000..c43193658b214a2
--- /dev/null
+++ b/llvm/test/MC/Mips/cop0-register-names.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -triple=mips -mcpu=mips32r2 -show-encoding %s | FileCheck %s
+# RUN: llvm-mc -triple=mips -mcpu=mips32r2 -filetype=obj %s | llvm-objdump -d - | FileCheck %s --check-prefix=DIS
+
+ mfc0 $2, $status # CHECK: mfc0 $2, $12, 0 # encoding: [0x40,0x02,0x60,0x00]
+ # DIS: mfc0 $2, $12, 0
+ mfc0 $2, $intctl # CHECK: mfc0 $2, $12, 1 # encoding: [0x40,0x02,0x60,0x01]
+ # DIS: mfc0 $2, $12, 1
+ mfc0 $2, $config # CHECK: mfc0 $2, $16, 0 # encoding: [0x40,0x02,0x80,0x00]
+ # DIS: mfc0 $2, $16, 0
+ mfc0 $2, $config1 # CHECK: mfc0 $2, $16, 1 # encoding: [0x40,0x02,0x80,0x01]
+ # DIS: mfc0 $2, $16, 1
+ mfc0 $2, $config1, 1 # CHECK: mfc0 $2, $16, 1 # encoding: [0x40,0x02,0x80,0x01]
+ # DIS: mfc0 $2, $16, 1
+ mtc0 $2, $ebase # CHECK: mtc0 $2, $15, 1 # encoding: [0x40,0x82,0x78,0x01]
+ # DIS: mtc0 $2, $15, 1
+ mtc0 $2, $kscratch6 # CHECK: mtc0 $2, $31, 7 # encoding: [0x40,0x82,0xf8,0x07]
+ # DIS: mtc0 $2, $31, 7
+
+# Numeric register aliases and absolute selector expressions are also accepted.
+ .set cp0reg, $16
+ .set cp0sel, 1
+ mfc0 $2, cp0reg, cp0sel # CHECK: mfc0 $2, $16, 1 # encoding: [0x40,0x02,0x80,0x01]
+ # DIS: mfc0 $2, $16, 1
+ .set cp0name, $config1
+ mfc0 $2, cp0name # CHECK: mfc0 $2, $16, 1 # encoding: [0x40,0x02,0x80,0x01]
+ # DIS: mfc0 $2, $16, 1
diff --git a/llvm/test/MC/Mips/mips-cop0-reginfo.s b/llvm/test/MC/Mips/mips-cop0-reginfo.s
index 3b4c5afb2e0d47f..97587e213494097 100644
--- a/llvm/test/MC/Mips/mips-cop0-reginfo.s
+++ b/llvm/test/MC/Mips/mips-cop0-reginfo.s
@@ -1,6 +1,6 @@
# RUN: llvm-mc -triple mips-unknown-linux-gnu -mcpu=mips32r2 -filetype=obj %s -o - \
# RUN: | llvm-readobj --sections --section-data - | FileCheck %s
- mfc0 $16, $15, 1
+ mfc0 $16, $ebase
mfc0 $16, $16, 1
diff --git a/llvm/test/MC/Mips/mt/mftr-mttr-aliases.s b/llvm/test/MC/Mips/mt/mftr-mttr-aliases.s
index 92e99fefc3dc166..44a1beacdf90b86 100644
--- a/llvm/test/MC/Mips/mt/mftr-mttr-aliases.s
+++ b/llvm/test/MC/Mips/mt/mftr-mttr-aliases.s
@@ -45,3 +45,6 @@
mttc1 $4, $f5 # CHECK: mttr $4, $5, 1, 2, 0 # encoding: [0x41,0x84,0x28,0x22]
mtthc1 $4, $f5 # CHECK: mttr $4, $5, 1, 2, 1 # encoding: [0x41,0x84,0x28,0x32]
cttc1 $4, $f9 # CHECK: mttr $4, $9, 1, 3, 0 # encoding: [0x41,0x84,0x48,0x23]
+
+ mftc0 $4, $config1 # CHECK: mftr $4, $16, 0, 1, 0 # encoding: [0x41,0x10,0x20,0x01]
+ mttc0 $4, $config1 # CHECK: mttr $4, $16, 0, 1, 0 # encoding: [0x41,0x84,0x80,0x01]
diff --git a/llvm/test/MC/Mips/virt/invalid.s b/llvm/test/MC/Mips/virt/invalid.s
index cfd3ce030fafdf5..6f0a6ea2daa521d 100644
--- a/llvm/test/MC/Mips/virt/invalid.s
+++ b/llvm/test/MC/Mips/virt/invalid.s
@@ -11,7 +11,7 @@
mfgc0 0 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
mfgc0 $4 # CHECK: :[[@LINE]]:3: error: too few operands for instruction
mfgc0 0, $4 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
- mfgc0 0, $4, $5 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+ mfgc0 0, $4, $5 # CHECK: :[[@LINE]]:16: error: expected 3-bit unsigned immediate
mfgc0 $4, 0, $5 # CHECK: :[[@LINE]]:13: error: invalid operand for instruction
mfgc0 $4, $5, 8 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
mfgc0 $4, $5, -1 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
@@ -20,7 +20,7 @@
mtgc0 0 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
mtgc0 $4 # CHECK: :[[@LINE]]:3: error: too few operands for instruction
mtgc0 0, $4 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
- mtgc0 0, $4, $5 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+ mtgc0 0, $4, $5 # CHECK: :[[@LINE]]:16: error: expected 3-bit unsigned immediate
mtgc0 $4, 0, $5 # CHECK: :[[@LINE]]:13: error: invalid operand for instruction
mtgc0 $4, $5, 8 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
mtgc0 $4, $5, -1 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
@@ -29,7 +29,7 @@
mfhgc0 0 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
mfhgc0 $4 # CHECK: :[[@LINE]]:3: error: too few operands for instruction
mfhgc0 0, $4 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
- mfhgc0 0, $4, $5 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
+ mfhgc0 0, $4, $5 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
mfhgc0 $4, 0, $5 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
mfhgc0 $4, $5, 8 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
mfhgc0 $4, $5, -1 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
@@ -38,7 +38,7 @@
mthgc0 0 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
mthgc0 $4 # CHECK: :[[@LINE]]:3: error: too few operands for instruction
mthgc0 0, $4 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
- mthgc0 0, $4, $5 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
+ mthgc0 0, $4, $5 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
mthgc0 $4, 0, $5 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
mthgc0 $4, $5, 8 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
mthgc0 $4, $5, -1 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
diff --git a/llvm/test/MC/Mips/virt/invalid64.s b/llvm/test/MC/Mips/virt/invalid64.s
index c92795684f45692..8efc22a593e19a6 100644
--- a/llvm/test/MC/Mips/virt/invalid64.s
+++ b/llvm/test/MC/Mips/virt/invalid64.s
@@ -7,7 +7,7 @@
dmfgc0 0 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
dmfgc0 $4 # CHECK: :[[@LINE]]:3: error: too few operands for instruction
dmfgc0 0, $4 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
- dmfgc0 0, $4, $5 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
+ dmfgc0 0, $4, $5 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
dmfgc0 $4, 0, $5 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
dmfgc0 $4, $5, 8 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
dmfgc0 $4, $5, -1 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
@@ -16,7 +16,7 @@
dmtgc0 0 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
dmtgc0 $4 # CHECK: :[[@LINE]]:3: error: too few operands for instruction
dmtgc0 0, $4 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
- dmtgc0 0, $4, $5 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
+ dmtgc0 0, $4, $5 # CHECK: :[[@LINE]]:17: error: expected 3-bit unsigned immediate
dmtgc0 $4, 0, $5 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
dmtgc0 $4, $5, 8 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
dmtgc0 $4, $5, -1 # CHECK: :[[@LINE]]:18: error: expected 3-bit unsigned immediate
More information about the llvm-commits
mailing list