Skip to content

Commit 84de019

Browse files
committed
[RISCV] Remove AnyReg RegisterClass used by .insn instructions. Use custom operand instead.
The fake register class interferes too much with the autogenerated register class tables. Especially the fake spill size. I'm working on .insn support for compressed instructions and adding AnyRegC broke CodeGen.
1 parent 77044a4 commit 84de019

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ struct RISCVOperand final : public MCParsedAsmOperand {
368368
bool isV0Reg() const {
369369
return Kind == KindTy::Register && Reg.RegNum == RISCV::V0;
370370
}
371+
bool isAnyReg() const {
372+
return Kind == KindTy::Register &&
373+
(RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains(Reg.RegNum) ||
374+
RISCVMCRegisterClasses[RISCV::FPR64RegClassID].contains(Reg.RegNum) ||
375+
RISCVMCRegisterClasses[RISCV::VRRegClassID].contains(Reg.RegNum));
376+
}
371377
bool isImm() const override { return Kind == KindTy::Immediate; }
372378
bool isMem() const override { return false; }
373379
bool isSystemRegister() const { return Kind == KindTy::SystemRegister; }

llvm/lib/Target/RISCV/RISCVInstrInfo.td

+11
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,17 @@ def : InstAlias<"zext.b $rd, $rs", (ANDI GPR:$rd, GPR:$rs, 0xFF), 0>;
10901090
// .insn directive instructions
10911091
//===----------------------------------------------------------------------===//
10921092

1093+
def AnyRegOperand : AsmOperandClass {
1094+
let Name = "AnyRegOperand";
1095+
let RenderMethod = "addRegOperands";
1096+
let PredicateMethod = "isAnyReg";
1097+
}
1098+
1099+
def AnyReg : Operand<XLenVT> {
1100+
let OperandType = "OPERAND_REGISTER";
1101+
let ParserMatchClass = AnyRegOperand;
1102+
}
1103+
10931104
// isCodeGenOnly = 1 to hide them from the tablegened assembly parser.
10941105
let isCodeGenOnly = 1, hasSideEffects = 1, mayLoad = 1, mayStore = 1,
10951106
hasNoSchedulingInfo = 1 in {

llvm/lib/Target/RISCV/RISCVRegisterInfo.td

-12
Original file line numberDiff line numberDiff line change
@@ -578,15 +578,3 @@ foreach m = LMULList.m in {
578578
// Special registers
579579
def FFLAGS : RISCVReg<0, "fflags">;
580580
def FRM : RISCVReg<0, "frm">;
581-
582-
// Any type register. Used for .insn directives when we don't know what the
583-
// register types could be.
584-
// NOTE: The alignment and size are bogus values. The Size needs to be non-zero
585-
// or tablegen will use "untyped" to determine the size which will assert.
586-
let isAllocatable = 0 in
587-
def AnyReg : RegisterClass<"RISCV", [untyped], 32,
588-
(add (sequence "X%u", 0, 31),
589-
(sequence "F%u_D", 0, 31),
590-
(sequence "V%u", 0, 31))> {
591-
let Size = 32;
592-
}

0 commit comments

Comments
 (0)