Skip to content

Commit a67e989

Browse files
committed
[RISCV] Add FallbackRegAltNameIndex to ABIRegAltName.
Remove now redundant fake ABI names from vector registers. This also fixes a crash that occurs if you use fflags as an instruction operand in the assembly and use -debug. It's not a valid register for any instruction since this wouldn't be common. It doesn't have an ABI name so it crashes the register printing in the debug output.
1 parent 164b046 commit a67e989

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class RISCVReg64<RISCVReg32 subreg>
4545
let SubRegIndices = [sub_32];
4646
}
4747

48+
let FallbackRegAltNameIndex = NoRegAltName in
4849
def ABIRegAltName : RegAltNameIndex;
4950

5051
def sub_vrm4_0 : SubRegIndex<256>;
@@ -415,51 +416,46 @@ class VRegList<list<dag> LIn, int start, int nf, int lmul, bit isV0> {
415416
}
416417

417418
// Vector registers
418-
let RegAltNameIndices = [ABIRegAltName] in {
419-
foreach Index = 0-31 in {
420-
def V#Index : RISCVReg<Index, "v"#Index, ["v"#Index]>, DwarfRegNum<[!add(Index, 96)]>;
421-
}
419+
foreach Index = 0-31 in {
420+
def V#Index : RISCVReg<Index, "v"#Index>, DwarfRegNum<[!add(Index, 96)]>;
421+
}
422422

423-
foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
424-
24, 26, 28, 30] in {
425-
def V#Index#M2 : RISCVRegWithSubRegs<Index, "v"#Index,
426-
[!cast<Register>("V"#Index),
427-
!cast<Register>("V"#!add(Index, 1))],
428-
["v"#Index]>,
429-
DwarfRegAlias<!cast<Register>("V"#Index)> {
430-
let SubRegIndices = [sub_vrm1_0, sub_vrm1_1];
431-
}
423+
foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
424+
24, 26, 28, 30] in {
425+
def V#Index#M2 : RISCVRegWithSubRegs<Index, "v"#Index,
426+
[!cast<Register>("V"#Index),
427+
!cast<Register>("V"#!add(Index, 1))]>,
428+
DwarfRegAlias<!cast<Register>("V"#Index)> {
429+
let SubRegIndices = [sub_vrm1_0, sub_vrm1_1];
432430
}
431+
}
433432

434-
foreach Index = [0, 4, 8, 12, 16, 20, 24, 28] in {
435-
def V#Index#M4 : RISCVRegWithSubRegs<Index, "v"#Index,
436-
[!cast<Register>("V"#Index#"M2"),
437-
!cast<Register>("V"#!add(Index, 2)#"M2")],
438-
["v"#Index]>,
439-
DwarfRegAlias<!cast<Register>("V"#Index)> {
440-
let SubRegIndices = [sub_vrm2_0, sub_vrm2_1];
441-
}
433+
foreach Index = [0, 4, 8, 12, 16, 20, 24, 28] in {
434+
def V#Index#M4 : RISCVRegWithSubRegs<Index, "v"#Index,
435+
[!cast<Register>("V"#Index#"M2"),
436+
!cast<Register>("V"#!add(Index, 2)#"M2")]>,
437+
DwarfRegAlias<!cast<Register>("V"#Index)> {
438+
let SubRegIndices = [sub_vrm2_0, sub_vrm2_1];
442439
}
440+
}
443441

444-
foreach Index = [0, 8, 16, 24] in {
445-
def V#Index#M8 : RISCVRegWithSubRegs<Index, "v"#Index,
446-
[!cast<Register>("V"#Index#"M4"),
447-
!cast<Register>("V"#!add(Index, 4)#"M4")],
448-
["v"#Index]>,
449-
DwarfRegAlias<!cast<Register>("V"#Index)> {
450-
let SubRegIndices = [sub_vrm4_0, sub_vrm4_1];
451-
}
442+
foreach Index = [0, 8, 16, 24] in {
443+
def V#Index#M8 : RISCVRegWithSubRegs<Index, "v"#Index,
444+
[!cast<Register>("V"#Index#"M4"),
445+
!cast<Register>("V"#!add(Index, 4)#"M4")]>,
446+
DwarfRegAlias<!cast<Register>("V"#Index)> {
447+
let SubRegIndices = [sub_vrm4_0, sub_vrm4_1];
452448
}
453-
454-
def VTYPE : RISCVReg<0, "vtype", ["vtype"]>;
455-
def VL : RISCVReg<0, "vl", ["vl"]>;
456-
def VXSAT : RISCVReg<0, "vxsat", ["vxsat"]>;
457-
def VXRM : RISCVReg<0, "vxrm", ["vxrm"]>;
458-
let isConstant = true in
459-
def VLENB : RISCVReg<0, "vlenb", ["vlenb"]>,
460-
DwarfRegNum<[!add(4096, SysRegVLENB.Encoding)]>;
461449
}
462450

451+
def VTYPE : RISCVReg<0, "vtype">;
452+
def VL : RISCVReg<0, "vl">;
453+
def VXSAT : RISCVReg<0, "vxsat">;
454+
def VXRM : RISCVReg<0, "vxrm">;
455+
let isConstant = true in
456+
def VLENB : RISCVReg<0, "vlenb">,
457+
DwarfRegNum<[!add(4096, SysRegVLENB.Encoding)]>;
458+
463459
def VCSR : RegisterClass<"RISCV", [XLenVT], 32,
464460
(add VTYPE, VL, VLENB)> {
465461
let RegInfos = XLenRI;

0 commit comments

Comments
 (0)